Sha256: 596754fa435169ada16978aad911b87f4529b9435d4d340273d6250ffd51f8f2

Contents?: true

Size: 418 Bytes

Versions: 7

Compression:

Stored size: 418 Bytes

Contents

require 'base64'

module Yoti
  class Image
    attr_reader :content
    attr_reader :mime_type

    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

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
yoti-1.6.4 lib/yoti/data_type/image.rb
yoti-1.6.3 lib/yoti/data_type/image.rb
yoti-1.6.2 lib/yoti/data_type/image.rb
yoti-1.6.1 lib/yoti/data_type/image.rb
yoti-1.6.0 lib/yoti/data_type/image.rb
yoti-1.5.0 lib/yoti/data_type/image.rb
yoti-1.4.0 lib/yoti/data_type/image.rb