Class: Gotenberg::Utilities::InlineResource

Inherits:
Object
  • Object
show all
Defined in:
lib/gotenberg/utilities/inline_resource.rb

Constant Summary collapse

MIME_TYPES =
{
  'bmp' => 'image/bmp',
  'gif' => 'image/gif',
  'png' => 'image/png',
  'jpe' => 'image/jpeg',
  'jpeg' => 'image/jpeg',
  'jpg' => 'image/jpeg',
  'jfif' => 'image/pipeg',
  'svg' => 'image/svg+xml',
  'tif' => 'image/tiff',
  'tiff' => 'image/tiff',
  'ico' => 'image/x-icon',
  'eot' => 'application/vnd.ms-fontobject',
  'otf' => 'application/font-sfnt',
  'ttf' => 'application/font-sfnt',
  'woff' => 'application/font-woff',
  'woff2' => 'application/font-woff2',
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, binary) ⇒ InlineResource

Returns a new instance of InlineResource.



27
28
29
30
# File 'lib/gotenberg/utilities/inline_resource.rb', line 27

def initialize filename, binary
  @filename = filename
  @binary = binary
end

Instance Attribute Details

#binaryObject (readonly)

Returns the value of attribute binary.



25
26
27
# File 'lib/gotenberg/utilities/inline_resource.rb', line 25

def binary
  @binary
end

#filenameObject (readonly)

Returns the value of attribute filename.



25
26
27
# File 'lib/gotenberg/utilities/inline_resource.rb', line 25

def filename
  @filename
end

Instance Method Details

#callObject



32
33
34
# File 'lib/gotenberg/utilities/inline_resource.rb', line 32

def call
  'data:%s;base64,%s' % [mimetype, Base64.strict_encode64(binary)]
end