Sha256: d745aac431f5cd5e0a3149fe6be780942e29515854ea87b98f7a42ca654356f5

Contents?: true

Size: 850 Bytes

Versions: 3

Compression:

Stored size: 850 Bytes

Contents

# frozen_string_literal: true
require 'dato/local/field_type/file'

module Dato
  module Local
    module FieldType
      class Image < Dato::Local::FieldType::File
        attr_reader :width, :height

        def self.parse(value, _repo)
          new(
            value[:path],
            value[:format],
            value[:size],
            value[:width],
            value[:height]
          )
        end

        def initialize(path, format, size, width, height)
          super(path, format, size)
          @width = width
          @height = height
        end

        alias raw_file file

        def file(host = default_host)
          super.ch('DPR', 'Width').auto('format')
        end

        def to_hash
          super.merge(
            width: width,
            height: height
          )
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dato-0.3.2 lib/dato/local/field_type/image.rb
dato-0.3.1 lib/dato/local/field_type/image.rb
dato-0.3.0 lib/dato/local/field_type/image.rb