Sha256: 3295daa15c5e1b1ebef27bb0eff8f213999f9b3cf08462b8a145217c74388cd8
Contents?: true
Size: 980 Bytes
Versions: 3
Compression:
Stored size: 980 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) value && new( value[:path], value[:format], value[:size] ) end def initialize(path, format, size) @path = path @format = format @size = size end def file(host = default_host) Imgix::Client.new( host: host, secure: true, include_library_param: false ).path(path) end def url(host: default_host, **opts) file(host).to_url(opts) end def to_hash { format: format, size: size, url: url } end private def default_host 'dato-images.imgix.net' end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dato-0.3.6 | lib/dato/local/field_type/file.rb |
dato-0.3.5 | lib/dato/local/field_type/file.rb |
dato-0.3.3 | lib/dato/local/field_type/file.rb |