Class: Jsm::Drawer::Digraph

Inherits:
Object
  • Object
show all
Defined in:
lib/jsm/drawer/digraph.rb

Overview

list of all nodes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state_machine) ⇒ Digraph

Returns a new instance of Digraph.



4
5
6
# File 'lib/jsm/drawer/digraph.rb', line 4

def initialize(state_machine)
  @state_machine = state_machine
end

Instance Attribute Details

#state_machineObject (readonly)

Returns the value of attribute state_machine.



3
4
5
# File 'lib/jsm/drawer/digraph.rb', line 3

def state_machine
  @state_machine
end

Instance Method Details

#nodesObject

list of all nodes TODO: move it to different class(?)



10
11
12
13
14
15
16
# File 'lib/jsm/drawer/digraph.rb', line 10

def nodes
  unless @nodes
    events = state_machine.events.values
    @nodes = events.map{ |event| to_nodes(event) }.flatten
  end
  @nodes
end

#to_sObject

convert it to string that is compatible with api Graphviz



19
20
21
# File 'lib/jsm/drawer/digraph.rb', line 19

def to_s
  nodes.map(&:to_s).join(';')
end