Class: Workflow::State
- Inherits:
-
Object
- Object
- Workflow::State
- Includes:
- Comparable
- Defined in:
- lib/workflow/state.rb
Instance Attribute Summary collapse
-
#events ⇒ Object
Returns the value of attribute events.
-
#meta ⇒ Object
Returns the value of attribute meta.
-
#name ⇒ Object
Returns the value of attribute name.
-
#on_entry ⇒ Object
Returns the value of attribute on_entry.
-
#on_exit ⇒ Object
Returns the value of attribute on_exit.
-
#spec ⇒ Object
readonly
Returns the value of attribute spec.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #<=>(other_state) ⇒ Object
- #draw(graph) ⇒ Object
-
#initialize(name, value, spec, meta = {}) ⇒ State
constructor
A new instance of State.
- #to_s ⇒ Object
- #to_sym ⇒ Object
Constructor Details
#initialize(name, value, spec, meta = {}) ⇒ State
Returns a new instance of State.
9 10 11 |
# File 'lib/workflow/state.rb', line 9 def initialize(name, value, spec, = {}) @name, @value, @spec, @events, @meta = name, value, spec, EventCollection.new, end |
Instance Attribute Details
#events ⇒ Object
Returns the value of attribute events.
6 7 8 |
# File 'lib/workflow/state.rb', line 6 def events @events end |
#meta ⇒ Object
Returns the value of attribute meta.
6 7 8 |
# File 'lib/workflow/state.rb', line 6 def @meta end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/workflow/state.rb', line 6 def name @name end |
#on_entry ⇒ Object
Returns the value of attribute on_entry.
6 7 8 |
# File 'lib/workflow/state.rb', line 6 def on_entry @on_entry end |
#on_exit ⇒ Object
Returns the value of attribute on_exit.
6 7 8 |
# File 'lib/workflow/state.rb', line 6 def on_exit @on_exit end |
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
7 8 9 |
# File 'lib/workflow/state.rb', line 7 def spec @spec end |
#value ⇒ Object
Returns the value of attribute value.
6 7 8 |
# File 'lib/workflow/state.rb', line 6 def value @value end |
Instance Method Details
#<=>(other_state) ⇒ Object
29 30 31 32 33 |
# File 'lib/workflow/state.rb', line 29 def <=>(other_state) states = spec.states.keys raise ArgumentError, "state `#{other_state}' does not exist" unless states.include?(other_state.to_sym) states.index(self.to_sym) <=> states.index(other_state.to_sym) end |
#draw(graph) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/workflow/state.rb', line 13 def draw(graph) defaults = { :label => to_s, :width => '1', :height => '1', :shape => 'ellipse' } node = graph.add_nodes(to_s, defaults) # Add open arrow for initial state # graph.add_edge(graph.add_node('starting_state', :shape => 'point'), node) if initial? node end |
#to_s ⇒ Object
35 36 37 |
# File 'lib/workflow/state.rb', line 35 def to_s "#{name}" end |
#to_sym ⇒ Object
39 40 41 |
# File 'lib/workflow/state.rb', line 39 def to_sym name.to_sym end |