class Workflow::State
Attributes
events[RW]
meta[RW]
name[RW]
on_entry[RW]
on_exit[RW]
spec[R]
Public Class Methods
new(name, spec, meta = {})
click to toggle source
# File lib/workflow/state.rb, line 6 def initialize(name, spec, meta = {}) @name, @spec, @events, @meta = name, spec, EventCollection.new, meta end
Public Instance Methods
<=>(other_state)
click to toggle source
# 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)
click to toggle source
# File lib/workflow/state.rb, line 10 def draw(graph) defaults = { :label => to_s, :width => '1', :height => '1', :shape => 'ellipse' } node = graph.add_nodes(to_s, defaults.merge(meta)) # Add open arrow for initial state # graph.add_edge(graph.add_node('starting_state', :shape => 'point'), node) if initial? node end
to_s()
click to toggle source
# File lib/workflow/state.rb, line 36 def to_s "#{name}" end
to_sym()
click to toggle source
# File lib/workflow/state.rb, line 40 def to_sym name.to_sym end