Sha256: aed43714f544a678a8c6ca80af1d2326cd93a582d32e8eb12763487213c64b0d

Contents?: true

Size: 833 Bytes

Versions: 5

Compression:

Stored size: 833 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

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

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dato-0.2.7 lib/dato/local/field_type/image.rb
dato-0.2.6 lib/dato/local/field_type/image.rb
dato-0.2.4 lib/dato/local/field_type/image.rb
dato-0.1.31 lib/dato/local/field_type/image.rb
dato-0.1.30 lib/dato/local/field_type/image.rb