Sha256: 835442773f10e07116a2d775919996b3be72223158793e4442a0f6d2a9bf51ab

Contents?: true

Size: 812 Bytes

Versions: 9

Compression:

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

9 entries across 9 versions & 1 rubygems

Version Path
dato-0.1.29 lib/dato/local/field_type/image.rb
dato-0.1.28 lib/dato/local/field_type/image.rb
dato-0.1.27 lib/dato/local/field_type/image.rb
dato-0.1.26 lib/dato/local/field_type/image.rb
dato-0.1.25 lib/dato/local/field_type/image.rb
dato-0.1.24 lib/dato/local/field_type/image.rb
dato-0.1.23 lib/dato/local/field_type/image.rb
dato-0.1.22 lib/dato/local/field_type/image.rb
dato-0.1.21 lib/dato/local/field_type/image.rb