Class: TermSlides::Diagram
- Inherits:
-
Object
- Object
- TermSlides::Diagram
- Defined in:
- lib/term-slides.rb
Instance Attribute Summary collapse
-
#dot ⇒ Object
readonly
Returns the value of attribute dot.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(renderer, dot, width = nil, height = nil) ⇒ Diagram
constructor
A new instance of Diagram.
- #render ⇒ Object
Constructor Details
#initialize(renderer, dot, width = nil, height = nil) ⇒ Diagram
Returns a new instance of Diagram.
158 159 160 161 162 163 |
# File 'lib/term-slides.rb', line 158 def initialize renderer, dot, width = nil, height = nil @renderer = renderer @dot = dot @width = width @height = height end |
Instance Attribute Details
#dot ⇒ Object (readonly)
Returns the value of attribute dot.
157 158 159 |
# File 'lib/term-slides.rb', line 157 def dot @dot end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
157 158 159 |
# File 'lib/term-slides.rb', line 157 def height @height end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
157 158 159 |
# File 'lib/term-slides.rb', line 157 def width @width end |
Instance Method Details
#build ⇒ Object
164 165 166 167 168 169 170 171 172 173 |
# File 'lib/term-slides.rb', line 164 def build $i ||= 0 path = Tempfile.new(['graph', ".png"]).path dot = 'dot' if find_executable dot `echo "#{@dot.gsub('"', '\\"')}" | #{dot} -Tpng > #{path}` $i += 1 end path end |
#render ⇒ Object
174 175 176 |
# File 'lib/term-slides.rb', line 174 def render @renderer.render_diagram self end |