Class: NxtStateMachine::Graph
- Inherits:
-
Object
- Object
- NxtStateMachine::Graph
- Defined in:
- lib/nxt_state_machine/graph.rb
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(state_machines, **options) ⇒ Graph
constructor
A new instance of Graph.
Constructor Details
#initialize(state_machines, **options) ⇒ Graph
Returns a new instance of Graph.
3 4 5 6 |
# File 'lib/nxt_state_machine/graph.rb', line 3 def initialize(state_machines, **) @state_machines = state_machines @options = .merge(**) end |
Instance Method Details
#draw ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/nxt_state_machine/graph.rb', line 8 def draw require 'ruby-graphviz' state_machines.each do |_, state_machine| add_nodes(state_machine) add_edges(state_machine) end filename = File.join([:path], "#{[:name]}.#{[:format]}") graph.output [:format] => filename puts '----------------------------------------------' puts 'Please run the following to open the generated file:' puts "open '#{filename}'" puts '----------------------------------------------' graph end |