Class: Billy::Brain

Inherits:
Object
  • Object
show all
Includes:
Config, Credentials, Disk, Knowledge, Settings, Skills
Defined in:
lib/billygoat/brain.rb

Instance Attribute Summary collapse

Attributes included from Skills

#skill_dir

Attributes included from Credentials

#credentials_file

Attributes included from Knowledge

#knowledge_file

Attributes included from Settings

#settings

Attributes included from Config

#config_dir, #root

Instance Method Summary collapse

Methods included from Skills

#find_skill, #skills, #skills_dir, #skills_path, #system_skills_path

Methods included from Credentials

#credentials, #credentials_path, #save_credentials

Methods included from Knowledge

#default_knowledge, #knowledge, #knowledge_path, #save_knowledge, #update_knowledge, #validate_knowledge

Methods included from Settings

#default_settings, #save_settings, #settings_file, #settings_path

Methods included from Config

#config_path, #create_config_path, #save_configuration

Methods included from Disk

#create_path, #save_yaml

Instance Attribute Details

#skillObject

Returns the value of attribute skill.



12
13
14
# File 'lib/billygoat/brain.rb', line 12

def skill
  @skill
end

Instance Method Details

#execute(*args) ⇒ Object

Execute a task in memory



48
49
50
51
52
53
54
55
56
# File 'lib/billygoat/brain.rb', line 48

def execute(*args)
  assert_skill_loaded

  if args.empty? || !skill.has_a_task?(args.first)
    args.unshift skill.default_task.name
  end

  memory.send *args
end

#forgetObject

Clear the workspace for executing tasks



30
31
32
# File 'lib/billygoat/brain.rb', line 30

def forget
  @memory = nil
end

#memoryObject

Short term memory serving as a workspace for executing tasks



18
19
20
21
22
23
24
25
# File 'lib/billygoat/brain.rb', line 18

def memory
  return @memory if @memory
  @memory = Memory.new
  @memory.brain = self
  @memory.credentials = credentials
  @memory.skills = skills
  @memory
end

#recall(name) ⇒ Object

Recall a skill and place it in memory



37
38
39
40
41
42
43
# File 'lib/billygoat/brain.rb', line 37

def recall(name)
  self.skill = find_skill(name)
  return unless skill

  require skill.internal_location if skill.internal_location
  memory.extend(skill.module)
end