Class: Svg2pdf::Processor

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

Instance Method Summary collapse

Constructor Details

#initialize(input, mode, format, options) ⇒ Processor

Returns a new instance of Processor.



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/svg2pdf.rb', line 53

def initialize(input, mode, format, options)
  @svg = input
  @mode = format
  @mode = :jpeg if @mode == :jpg
  setup_options options
  if mode == :from_data
    @handle = RSVG::Handle.new_from_data(@svg)
  else
    @handle = RSVG::Handle.new_from_file(@svg)
  end
end

Instance Method Details

#processObject



65
66
67
68
69
70
71
# File 'lib/svg2pdf.rb', line 65

def process
  case @mode
    when :jpeg, :jpg, :png  then render_image
    when :pdf, :ps          then render
    else raise Svg2pdf::UnsupportedFormatError, "Invalid output format: %s" % @mode.to_s
  end
end