Class: RMachine::Event

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event_name) ⇒ Event

Returns a new instance of Event.



5
6
7
8
# File 'lib/r_machine/event.rb', line 5

def initialize(event_name)
  @event_name = event_name
  @rules = []
end

Instance Attribute Details

#event_nameObject (readonly)

Returns the value of attribute event_name.



3
4
5
# File 'lib/r_machine/event.rb', line 3

def event_name
  @event_name
end

#rulesObject (readonly)

Returns the value of attribute rules.



3
4
5
# File 'lib/r_machine/event.rb', line 3

def rules
  @rules
end

Instance Method Details

#change_to(state, rule_options = {}) ⇒ Object



10
11
12
13
# File 'lib/r_machine/event.rb', line 10

def change_to(state, rule_options={})
  rule = Rule.new({new_state: state}.merge(rule_options))
  rules.push(rule)
end