Class: StateFu::State
Instance Attribute Summary collapse
-
#entry_requirements ⇒ Object
(also: #requirements)
readonly
Returns the value of attribute entry_requirements.
-
#exit_requirements ⇒ Object
readonly
Returns the value of attribute exit_requirements.
-
#own_events ⇒ Object
readonly
Returns the value of attribute own_events.
Attributes inherited from Sprocket
Instance Method Summary collapse
- #after?(other) ⇒ Boolean
- #before?(other) ⇒ Boolean
- #events ⇒ Object
-
#initialize(machine, name, options = {}) ⇒ State
constructor
A new instance of State.
-
#inspect ⇒ Object
display nice and short.
Methods inherited from Sprocket
#==, #===, #add_hook, #deep_copy, #lathe, #serializable?, #to_s
Methods included from HasOptions
Methods included from Applicable
Constructor Details
#initialize(machine, name, options = {}) ⇒ State
Returns a new instance of State.
7 8 9 10 11 12 |
# File 'lib/state.rb', line 7 def initialize(machine, name, ={}) @entry_requirements = [].extend ArrayWithSymbolAccessor @exit_requirements = [].extend ArrayWithSymbolAccessor @own_events = [].extend EventArray super( machine, name, ) end |
Instance Attribute Details
#entry_requirements ⇒ Object (readonly) Also known as: requirements
Returns the value of attribute entry_requirements.
4 5 6 |
# File 'lib/state.rb', line 4 def entry_requirements @entry_requirements end |
#exit_requirements ⇒ Object (readonly)
Returns the value of attribute exit_requirements.
4 5 6 |
# File 'lib/state.rb', line 4 def exit_requirements @exit_requirements end |
#own_events ⇒ Object (readonly)
Returns the value of attribute own_events.
4 5 6 |
# File 'lib/state.rb', line 4 def own_events @own_events end |
Instance Method Details
#after?(other) ⇒ Boolean
22 23 24 |
# File 'lib/state.rb', line 22 def after?(other) machine.states.index(self) > machine.states.index(machine.states[other]) end |
#before?(other) ⇒ Boolean
18 19 20 |
# File 'lib/state.rb', line 18 def before?(other) machine.states.index(self) < machine.states.index(machine.states[other]) end |
#events ⇒ Object
14 15 16 |
# File 'lib/state.rb', line 14 def events machine.events.from(self) end |
#inspect ⇒ Object
display nice and short
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/state.rb', line 27 def inspect s = self.to_s s = s[0,s.length-1] display_hooks = hooks.dup display_hooks.each do |k,v| display_hooks.delete(k) if v.empty? end unless display_hooks.empty? s << " hooks=#{display_hooks.inspect}" end unless entry_requirements.empty? s << " entry_requirements=#{entry_requirements.inspect}" end unless exit_requirements.empty? s << " exit_requirements=#{exit_requirements.inspect}" end s << ">" s end |