Class: HAL9000::ActionStore

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeActionStore

Returns a new instance of ActionStore.



8
9
10
# File 'lib/hal9000/actionstore.rb', line 8

def initialize
  @actions = []
end

Instance Attribute Details

#actionsObject

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

#listObject



28
29
30
31
32
# File 'lib/hal9000/actionstore.rb', line 28

def list
  actions.sort.each do |action|
    puts action
  end
end