Class: HAL9000::ActionStore
- Inherits:
-
Object
- Object
- HAL9000::ActionStore
- Defined in:
- lib/hal9000/actionstore.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
Returns the value of attribute actions.
Instance Method Summary collapse
- #add_action(action) ⇒ Object
- #delete_action(thought) ⇒ Object
- #find_action(thought) ⇒ Object
-
#initialize ⇒ ActionStore
constructor
A new instance of ActionStore.
- #list ⇒ Object
Constructor Details
#initialize ⇒ ActionStore
Returns a new instance of ActionStore.
8 9 10 |
# File 'lib/hal9000/actionstore.rb', line 8 def initialize @actions = [] end |
Instance Attribute Details
#actions ⇒ Object
Returns the value of attribute actions.
6 7 8 |
# File 'lib/hal9000/actionstore.rb', line 6 def actions @actions end |
Instance Method Details
#add_action(action) ⇒ Object
12 13 14 15 16 |
# File 'lib/hal9000/actionstore.rb', line 12 def add_action(action) unless find_action(action.thought) actions << action end end |
#delete_action(thought) ⇒ Object
24 25 26 |
# File 'lib/hal9000/actionstore.rb', line 24 def delete_action(thought) actions.reject! { |action| action.thought == thought } end |
#find_action(thought) ⇒ Object
18 19 20 21 22 |
# File 'lib/hal9000/actionstore.rb', line 18 def find_action(thought) actions.find do |action| action.thought.casecmp(thought) == 0 end end |
#list ⇒ Object
28 29 30 31 32 |
# File 'lib/hal9000/actionstore.rb', line 28 def list actions.sort.each do |action| puts action end end |