Class: StateShifter::State
- Inherits:
-
Object
- Object
- StateShifter::State
- Defined in:
- lib/state_shifter/state.rb
Instance Attribute Summary collapse
-
#entry_callback ⇒ Object
Returns the value of attribute entry_callback.
-
#entry_callback_args ⇒ Object
Returns the value of attribute entry_callback_args.
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#initial ⇒ Object
readonly
Returns the value of attribute initial.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #draw(graph, options) ⇒ Object
- #final? ⇒ Boolean
- #has_entry_callback? ⇒ Boolean
- #initial? ⇒ Boolean
-
#initialize(name, initial = false) ⇒ State
constructor
A new instance of State.
Constructor Details
#initialize(name, initial = false) ⇒ State
Returns a new instance of State.
8 9 10 11 12 13 14 |
# File 'lib/state_shifter/state.rb', line 8 def initialize name, initial=false @name = name @events = {} @initial = initial @entry_callback = nil @entry_callback_args = nil end |
Instance Attribute Details
#entry_callback ⇒ Object
Returns the value of attribute entry_callback.
6 7 8 |
# File 'lib/state_shifter/state.rb', line 6 def entry_callback @entry_callback end |
#entry_callback_args ⇒ Object
Returns the value of attribute entry_callback_args.
6 7 8 |
# File 'lib/state_shifter/state.rb', line 6 def entry_callback_args @entry_callback_args end |
#events ⇒ Object (readonly)
Returns the value of attribute events.
5 6 7 |
# File 'lib/state_shifter/state.rb', line 5 def events @events end |
#initial ⇒ Object (readonly)
Returns the value of attribute initial.
5 6 7 |
# File 'lib/state_shifter/state.rb', line 5 def initial @initial end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/state_shifter/state.rb', line 5 def name @name end |
Instance Method Details
#draw(graph, options) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/state_shifter/state.rb', line 28 def draw graph, node = graph.add_nodes(@name.to_s, :label => @name.to_s, :width => '1', :height => '1', :shape => final? ? 'doublecircle' : 'ellipse' ) graph.add_edges(graph.add_nodes('starting_state', :shape => 'point'), node) if initial? node end |
#final? ⇒ Boolean
24 25 26 |
# File 'lib/state_shifter/state.rb', line 24 def final? @events.empty? end |
#has_entry_callback? ⇒ Boolean
16 17 18 |
# File 'lib/state_shifter/state.rb', line 16 def has_entry_callback? !@entry_callback.nil? end |
#initial? ⇒ Boolean
20 21 22 |
# File 'lib/state_shifter/state.rb', line 20 def initial? @initial end |