Class: StrictMachine::State
- Defined in:
- lib/strict_machine/definition/state.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#on_entry ⇒ Object
readonly
Returns the value of attribute on_entry.
-
#transition_definitions ⇒ Object
readonly
Returns the value of attribute transition_definitions.
Instance Method Summary collapse
- #add_on_entry(proc) ⇒ Object
- #add_transition(transition_definition) ⇒ Object
- #get_transition(name, is_bang) ⇒ Object
-
#initialize(name) ⇒ State
constructor
A new instance of State.
Constructor Details
#initialize(name) ⇒ State
Returns a new instance of State.
7 8 9 10 11 |
# File 'lib/strict_machine/definition/state.rb', line 7 def initialize(name) @name = name.to_sym @transition_definitions = [] @on_entry = [] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/strict_machine/definition/state.rb', line 5 def name @name end |
#on_entry ⇒ Object (readonly)
Returns the value of attribute on_entry.
5 6 7 |
# File 'lib/strict_machine/definition/state.rb', line 5 def on_entry @on_entry end |
#transition_definitions ⇒ Object (readonly)
Returns the value of attribute transition_definitions.
5 6 7 |
# File 'lib/strict_machine/definition/state.rb', line 5 def transition_definitions @transition_definitions end |
Instance Method Details
#add_on_entry(proc) ⇒ Object
29 30 31 |
# File 'lib/strict_machine/definition/state.rb', line 29 def add_on_entry(proc) @on_entry << proc end |
#add_transition(transition_definition) ⇒ Object
13 14 15 16 17 |
# File 'lib/strict_machine/definition/state.rb', line 13 def add_transition(transition_definition) @transition_definitions << TransitionDefinition.new( transition_definition ) end |
#get_transition(name, is_bang) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/strict_machine/definition/state.rb', line 19 def get_transition(name, is_bang) name = name [0..-2] if is_bang @transition_definitions.each do |this_transition| return this_transition if this_transition.name == name.to_sym end raise TransitionNotFoundError, name end |