Class: Goon
- Inherits:
-
Object
- Object
- Goon
- Defined in:
- lib/goon.rb,
lib/goon/version.rb
Defined Under Namespace
Classes: Competency, Task
Constant Summary collapse
- VERSION =
'0.0.3'
Instance Attribute Summary collapse
-
#competencies ⇒ Object
readonly
Returns the value of attribute competencies.
-
#facts ⇒ Object
readonly
Returns the value of attribute facts.
-
#task ⇒ Object
readonly
Returns the value of attribute task.
Instance Method Summary collapse
- #forget(name) ⇒ Object
-
#initialize(options = {}) ⇒ Goon
constructor
A new instance of Goon.
- #learn_competencies(competencies) ⇒ Object
- #learn_competency(competency) ⇒ Object
- #recall(name) ⇒ Object
-
#remember(options = {}) ⇒ Object
end.
- #run ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Goon
Returns a new instance of Goon.
6 7 8 9 10 11 12 |
# File 'lib/goon.rb', line 6 def initialize( = {}) competencies = [:competencies] || [] @competencies = [] @task = [:task] @facts = [:facts] || {} learn_competencies(competencies) end |
Instance Attribute Details
#competencies ⇒ Object (readonly)
Returns the value of attribute competencies.
4 5 6 |
# File 'lib/goon.rb', line 4 def competencies @competencies end |
#facts ⇒ Object (readonly)
Returns the value of attribute facts.
4 5 6 |
# File 'lib/goon.rb', line 4 def facts @facts end |
#task ⇒ Object (readonly)
Returns the value of attribute task.
4 5 6 |
# File 'lib/goon.rb', line 4 def task @task end |
Instance Method Details
#forget(name) ⇒ Object
50 51 52 |
# File 'lib/goon.rb', line 50 def forget(name) @facts.delete(name) end |
#learn_competencies(competencies) ⇒ Object
25 26 27 28 29 |
# File 'lib/goon.rb', line 25 def learn_competencies(competencies) competencies.each do |competency| learn_competency(competency) end end |
#learn_competency(competency) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/goon.rb', line 14 def learn_competency(competency) unless @competencies.include? competency instance_eval <<-EOS def #{competency.name}(options = {}) #{competency.body} end EOS @competencies << competency end end |
#recall(name) ⇒ Object
46 47 48 |
# File 'lib/goon.rb', line 46 def recall(name) @facts[name] end |
#remember(options = {}) ⇒ Object
end
42 43 44 |
# File 'lib/goon.rb', line 42 def remember( = {}) @facts.merge!() end |
#run ⇒ Object
54 55 56 57 |
# File 'lib/goon.rb', line 54 def run instance_eval @task.body @facts end |