Class: Imaginator::Graphviz

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

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Graphviz

Returns a new instance of Graphviz.



106
107
108
109
110
111
112
# File 'lib/imaginator.rb', line 106

def initialize(opts = {})
  @opts = {
    :format => 'png',
    :cmd    => 'dot'
  }
  @opts.update(opts)
end

Instance Method Details

#formatObject



114
115
116
# File 'lib/imaginator.rb', line 114

def format
  @opts[:format]
end

#process(code) ⇒ Object



125
126
127
# File 'lib/imaginator.rb', line 125

def process(code)
  code.strip
end

#render(code, file) ⇒ Object



118
119
120
121
122
123
# File 'lib/imaginator.rb', line 118

def render(code, file)
  IO.popen(@opts[:cmd] + " -T #{@opts[:format]} -o #{file}", 'w') {|io|
    io.write(code)
    io.close
  }
end