Class: DYI::Formatter::PngFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/dyi/formatter/svg_formatter.rb

Overview

Since:

  • 1.0.0

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ PngFormatter

Returns a new instance of PngFormatter.

Since:

  • 1.0.0



813
814
815
# File 'lib/dyi/formatter/svg_formatter.rb', line 813

def initialize(*args)
  @svg_formatter = SvgFormatter.new(*args)
end

Instance Method Details

#save(file_name, options = {}) ⇒ Object

Since:

  • 1.0.0



797
798
799
800
801
# File 'lib/dyi/formatter/svg_formatter.rb', line 797

def save(file_name, options={})
  IO.popen("rsvg-convert -f png -o #{file_name}", 'w+b') {|io|
    io.puts(@svg_formatter.string)
  }
end

#stringObject

Since:

  • 1.0.0



803
804
805
806
807
808
809
810
811
# File 'lib/dyi/formatter/svg_formatter.rb', line 803

def string
  results = ''
  IO.popen("rsvg-convert -f png", 'w+') {|io|
    io.puts(@svg_formatter.string)
    io.close_write
    io.read(nil, results)
  }
  results
end