Class: Flowchartviz

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(s, truthlabels: %i(yes no))) ⇒ Flowchartviz

Returns a new instance of Flowchartviz.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/flowchartviz.rb', line 13

def initialize(s,truthlabels: i(yes no))        
  
  @true, @false = truthlabels
  
  plaintext = scan(LineTree.new(s).to_a).flatten.compact.join("\n")

@raw_doc="<?polyrex schema='items[direction]/item[label, connection, shape]' delimiter =' # '?>\ndirection: TB\n\#{plaintext}\n"

  @pxg = PxGraphViz.new(@raw_doc)
 
end

Instance Attribute Details

#raw_docObject (readonly)

Returns the value of attribute raw_doc.



11
12
13
# File 'lib/flowchartviz.rb', line 11

def raw_doc
  @raw_doc
end

Instance Method Details

#export(file = 'gvml.xml') ⇒ Object Also known as: export_as



29
30
31
# File 'lib/flowchartviz.rb', line 29

def export(file='gvml.xml')
  File.write file, @pxg.to_doc.xml(pretty: true)    
end

#import(s) ⇒ Object



35
36
37
# File 'lib/flowchartviz.rb', line 35

def import(s)
  @pxg = PxGraphViz.new(RXFHelper.read(s).first)
end

#to_png(filename) ⇒ Object



39
40
41
# File 'lib/flowchartviz.rb', line 39

def to_png(filename)
  @pxg.to_png filename
end

#to_svg(filename) ⇒ Object



43
44
45
# File 'lib/flowchartviz.rb', line 43

def to_svg(filename)
  @pxg.to_svg filename
end