class Stateoscope::Graph
Attributes
final_states[RW]
initial_state[RW]
states[RW]
transitions[RW]
Public Class Methods
new()
click to toggle source
# File lib/stateoscope/graph.rb, line 7 def initialize self.states = [] self.final_states = [] self.transitions = [] end
Public Instance Methods
add_state(state)
click to toggle source
# File lib/stateoscope/graph.rb, line 13 def add_state(state) states << state end
add_transition(from, to, event = nil)
click to toggle source
# File lib/stateoscope/graph.rb, line 17 def add_transition(from, to, event = nil) transitions << OpenStruct.new(from: from, to: to, event: event) end
detect_final_states!()
click to toggle source
# File lib/stateoscope/graph.rb, line 21 def detect_final_states! self.final_states = states - transitions.map(&:from) end
final_state?(state)
click to toggle source
# File lib/stateoscope/graph.rb, line 25 def final_state?(state) final_states.include?(state) end