Sha256: 54e0809b1dd79bbef5b7f7954eec38e3b13ba5e5bfc0a96cf105280f6a145c5b

Contents?: true

Size: 682 Bytes

Versions: 10

Compression:

Stored size: 682 Bytes

Contents

# frozen_string_literal: true
require 'imgix'

module Dato
  module Local
    module FieldType
      class File
        attr_reader :path, :format, :size

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

        def initialize(path, format, size)
          @path = path
          @format = format
          @size = size
        end

        def file
          Imgix::Client.new(
            host: 'dato-images.imgix.net',
            secure: true
          ).path(path)
        end

        def url(*args)
          file.to_url(*args)
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
dato-0.1.20 lib/dato/local/field_type/file.rb
dato-0.1.19 lib/dato/local/field_type/file.rb
dato-0.1.18 lib/dato/local/field_type/file.rb
dato-0.1.17 lib/dato/local/field_type/file.rb
dato-0.1.16 lib/dato/local/field_type/file.rb
dato-0.1.15 lib/dato/local/field_type/file.rb
dato-0.1.14 lib/dato/local/field_type/file.rb
dato-0.1.13 lib/dato/local/field_type/file.rb
dato-0.1.12 lib/dato/local/field_type/file.rb
dato-0.1.11 lib/dato/local/field_type/file.rb