Sha256: f9b17e923ad0253ef441492aea4b5ca60a68de0218a84d355b57217df1a52e3f

Contents?: true

Size: 1.26 KB

Versions: 4

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

module Yoti
  module Sandbox
    module Profile
      class DocumentImages
        #
        # @param [Array<Image>] images
        #
        def initialize(images)
          Validation.assert_is_a(Array, images, 'images')
          @images = images
        end

        #
        # @return [DocumentImagesBuilder]
        #
        def self.builder
          DocumentImagesBuilder.new
        end

        #
        # @return [String]
        #
        def value
          @images
            .map(&:base64_content)
            .join('&')
        end
      end

      #
      # Builder for {DocumentImages}
      #
      class DocumentImagesBuilder
        def initialize
          @images = []
        end

        #
        # @param [bin] content
        #
        # @return [self]
        #
        def with_jpeg_content(content)
          @images << Yoti::ImageJpeg.new(content)
          self
        end

        #
        # @param [bin] content
        #
        # @return [self]
        #
        def with_png_content(content)
          @images << Yoti::ImagePng.new(content)
          self
        end

        #
        # @return [DocumentImages]
        #
        def build
          DocumentImages.new(@images)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
yoti_sandbox-1.4.0 lib/yoti_sandbox/profile/document_images.rb
yoti_sandbox-1.3.0 lib/yoti_sandbox/profile/document_images.rb
yoti_sandbox-1.2.1 lib/yoti_sandbox/profile/document_images.rb
yoti_sandbox-1.2.0 lib/yoti_sandbox/profile/document_images.rb