Class: Petrinet::GraphvizBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/petrinet/graphviz_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(net, transition_vector_by_transition_name, place_name_by_place_index, state_vector) ⇒ GraphvizBuilder

Returns a new instance of GraphvizBuilder.



6
7
8
9
10
11
# File 'lib/petrinet/graphviz_builder.rb', line 6

def initialize(net, transition_vector_by_transition_name, place_name_by_place_index, state_vector)
  @net = net
  @transition_vectors_by_transition_name = transition_vector_by_transition_name
  @place_name_by_place_index = place_name_by_place_index
  @state_vector = state_vector
end

Instance Method Details

#svgObject

Generates an SVG for a net



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/petrinet/graphviz_builder.rb', line 14

def svg
  dot_source = dot
  dotfile = Tempfile.new("petrinet.dot")
  dotfile.write(dot_source)
  dotfile.close
  svgfile = Tempfile.new('petrinet.svg')
  # circo dot fdp neato nop nop1 nop2 osage patchwork sfdp twopi
  `dot -T svg -Kdot #{dotfile.path} -o #{svgfile.path}`
  `cat #{svgfile.path}`
  svg = svgfile.read
  processed_svg(svg)
end