Class: FSM::Transition
- Inherits:
-
Object
- Object
- FSM::Transition
- Includes:
- Options::InstanceMethods
- Defined in:
- lib/fsm/transition.rb
Instance Attribute Summary collapse
-
#event ⇒ Object
Returns the value of attribute event.
-
#from ⇒ Object
Returns the value of attribute from.
-
#name ⇒ Object
Returns the value of attribute name.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
- #fire_event(target, args) ⇒ Object
-
#initialize(name, from, to, options = {}) ⇒ Transition
constructor
A new instance of Transition.
- #to_s ⇒ Object
Methods included from Options::InstanceMethods
Constructor Details
#initialize(name, from, to, options = {}) ⇒ Transition
Returns a new instance of Transition.
5 6 7 8 9 10 11 12 |
# File 'lib/fsm/transition.rb', line 5 def initialize(name, from, to, = {}) raise ArgumentError.new("name, from and to are required but were '#{name}', '#{from}' and '#{to}'") unless name && from && to (, [:event]) self.name = name self.from = from self.to = to self.event = Executable.new [:event] if .has_key?(:event) end |
Instance Attribute Details
#event ⇒ Object
Returns the value of attribute event.
4 5 6 |
# File 'lib/fsm/transition.rb', line 4 def event @event end |
#from ⇒ Object
Returns the value of attribute from.
4 5 6 |
# File 'lib/fsm/transition.rb', line 4 def from @from end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/fsm/transition.rb', line 4 def name @name end |
#to ⇒ Object
Returns the value of attribute to.
4 5 6 |
# File 'lib/fsm/transition.rb', line 4 def to @to end |
Instance Method Details
#fire_event(target, args) ⇒ Object
14 15 16 |
# File 'lib/fsm/transition.rb', line 14 def fire_event(target, args) self.event.execute(target, *args) if self.event end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/fsm/transition.rb', line 18 def to_s "Transition from #{self.from.name} -> #{self.to.name} with event #{self.event}" end |