Class: Yoti::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/yoti/data_type/image.rb

Direct Known Subclasses

ImageJpeg, ImagePng

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content, mime_type) ⇒ Image

Returns a new instance of Image.

Raises:

  • (TypeError)


8
9
10
11
12
13
# File 'lib/yoti/data_type/image.rb', line 8

def initialize(content, mime_type)
  raise(TypeError, 'Image is an abstract class, so cannot be instantiated') if self.class == Yoti::Image

  @content = content
  @mime_type = mime_type
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



5
6
7
# File 'lib/yoti/data_type/image.rb', line 5

def content
  @content
end

#mime_typeObject (readonly)

Returns the value of attribute mime_type.



6
7
8
# File 'lib/yoti/data_type/image.rb', line 6

def mime_type
  @mime_type
end

Instance Method Details

#base64_contentObject



15
16
17
# File 'lib/yoti/data_type/image.rb', line 15

def base64_content
  "data:#{mime_type};base64,#{Base64.strict_encode64(content)}"
end