Module: Learn
- Defined in:
- lib/skills/learn.rb
Instance Method Summary collapse
-
#directory(path) ⇒ Object
Learn a set of new tasks described in a local directory.
-
#file(path) ⇒ Object
Learn a new task described in a local file.
Instance Method Details
#directory(path) ⇒ Object
Learn a set of new tasks described in a local directory
29 30 31 32 33 |
# File 'lib/skills/learn.rb', line 29 def directory(path) Dir.glob("#{path}/*.rb").each do |path| file(path) end end |
#file(path) ⇒ Object
Learn a new task described in a local file
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/skills/learn.rb', line 6 def file(path) self.filepath = filepath puts "Learning the skill from file #{@filepath}" assert_file_exists create_stash stash_file slate = Module.new slate.module_eval(File.read(internal_location)) skill_name = slate.constants.first.to_s skill = Billy::Skill.new( name: skill_name, internal_location: internal_location ) brain.skill_set.skills << skill brain.update_knowledge brain.save_knowledge end |