Class: Twb::Util::DotFileRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/twb/util/dotfilerenderer.rb

Constant Summary collapse

@@gvDotLocation =
'C:\\tech\\graphviz\\Graphviz2.38\\bin\\dot.exe'
@@renderTypes =
[:pdf, :png, :svg]

Instance Method Summary collapse

Constructor Details

#initializeDotFileRenderer

Returns a new instance of DotFileRenderer.


23
24
25
# File 'lib/twb/util/dotfilerenderer.rb', line 23

def initialize
  @gvDotLocation = @@gvDotLocation
end

Instance Method Details

#gvDotLocation=(location) ⇒ Object


27
28
29
# File 'lib/twb/util/dotfilerenderer.rb', line 27

def gvDotLocation=(location)
  @gvDotLocation = location
end

#render(dotFile, type) ⇒ Object


39
40
41
42
43
44
45
46
47
48
# File 'lib/twb/util/dotfilerenderer.rb', line 39

def render(dotFile, type)
  if @@renderTypes.include?(type)
    typeParam         = '-T' + type.to_s
    renderedFile      = dotFile.sub(/.dot$/,'') + '.' + type.to_s
    renderedFileParam = '-o' + renderedFile
    #puts "\t <render cmd> system #{@gvDotLocation}, #{typeParam}, #{renderedFileParam}, #{dotFile} "
    system @gvDotLocation, typeParam, renderedFileParam, dotFile
  end
  return renderedFile
end

#renderAll(dotFile) ⇒ Object


31
32
33
34
35
36
37
# File 'lib/twb/util/dotfilerenderer.rb', line 31

def renderAll(dotFile)
  renderedFiles = []
  @@renderTypes.each do |type|
    renderedFiles << render(dotFile,type)
  end
  return renderedFiles
end