Class: Sheldon
- Inherits:
-
Object
- Object
- Sheldon
- Defined in:
- lib/sheldon/sheldon.rb
Constant Summary collapse
- VERSION =
"0.2.7".freeze
Instance Attribute Summary collapse
-
#brain ⇒ Object
readonly
Returns the value of attribute brain.
-
#builder ⇒ Object
readonly
Returns the value of attribute builder.
Instance Method Summary collapse
- #build(abs_learn_path) ⇒ Object
-
#initialize(sheldon_data_dir, opts = {}) ⇒ Sheldon
constructor
A new instance of Sheldon.
- #learn(recall_cue, abs_learn_path) ⇒ Object
- #list_cues ⇒ Object
- #recall(recall_cue) ⇒ Object
Constructor Details
#initialize(sheldon_data_dir, opts = {}) ⇒ Sheldon
Returns a new instance of Sheldon.
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
#brain ⇒ Object (readonly)
Returns the value of attribute brain.
5 6 7 |
# File 'lib/sheldon/sheldon.rb', line 5 def brain @brain end |
#builder ⇒ Object (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_cues ⇒ Object
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 |