Class: Sheldon

Inherits:
Object
  • Object
show all
Defined in:
lib/sheldon/sheldon.rb

Constant Summary collapse

VERSION =
"0.2.7".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sheldon_data_dir, opts = {}) ⇒ Sheldon

Returns a new instance of Sheldon.

Raises:



7
8
9
10
11
# File 'lib/sheldon/sheldon.rb', line 7

def initialize(sheldon_data_dir, opts = {})
  raise MissingDataDirectoryException unless Dir.exists?(sheldon_data_dir)
  @brain = opts[:brain] || Brain.new(sheldon_data_dir)
  @builder = opts[:builder] || Builder.new
end

Instance Attribute Details

#brainObject (readonly)

Returns the value of attribute brain.



5
6
7
# File 'lib/sheldon/sheldon.rb', line 5

def brain
  @brain
end

#builderObject (readonly)

Returns the value of attribute builder.



5
6
7
# File 'lib/sheldon/sheldon.rb', line 5

def builder
  @builder
end

Instance Method Details

#build(abs_learn_path) ⇒ Object



13
14
15
# File 'lib/sheldon/sheldon.rb', line 13

def build(abs_learn_path)
  builder.build(abs_learn_path)
end

#learn(recall_cue, abs_learn_path) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/sheldon/sheldon.rb', line 17

def learn(recall_cue, abs_learn_path)
  if brain.has_cue?(recall_cue)
    raise "This cue has already been used."
  else
    brain.learn(recall_cue, abs_learn_path)
    brain.recall(recall_cue)
  end
end

#list_cuesObject



26
27
28
# File 'lib/sheldon/sheldon.rb', line 26

def list_cues
  brain.list_cues
end

#recall(recall_cue) ⇒ Object



30
31
32
33
# File 'lib/sheldon/sheldon.rb', line 30

def recall(recall_cue)
  raise "Cue '#{recall_cue}' could not be found." unless brain.has_cue?(recall_cue)
  brain.recall(recall_cue)
end