Class: DocPDF::Converter

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source = nil, **options) ⇒ Converter

Returns a new instance of Converter.



9
10
11
# File 'lib/docpdf/converter.rb', line 9

def initialize(source = nil, **options)
  @input = InputNormalizer.new(source, **options.slice(:io, :data, :filename, :mime_type))
end

Class Method Details

.call(source = nil, **options) ⇒ Object



4
5
6
# File 'lib/docpdf/converter.rb', line 4

def call(source = nil, **options)
  new(source, **options).call
end

Instance Method Details

#call ⇒ Object



13
14
15
16
17
# File 'lib/docpdf/converter.rb', line 13

def call
  data = ConverterResolver.resolve(@input.mime_type).convert(@input.data, @input.source_filename || @input.filename)
  filename = build_filename(@input.filename)
  Result.new(data: data, filename: filename)
end