Class: Flowchartviz
- Inherits:
-
Object
- Object
- Flowchartviz
- Defined in:
- lib/flowchartviz.rb
Instance Attribute Summary collapse
-
#raw_doc ⇒ Object
readonly
Returns the value of attribute raw_doc.
Instance Method Summary collapse
- #export(file = 'gvml.xml') ⇒ Object (also: #export_as)
- #import(s) ⇒ Object
-
#initialize(s, truthlabels: %i(yes no))) ⇒ Flowchartviz
constructor
A new instance of Flowchartviz.
- #to_png(filename) ⇒ Object
- #to_svg(filename) ⇒ Object
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_doc ⇒ Object (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 |