Class: Dato::Local::FieldType::File

Inherits:
Object
  • Object
show all
Defined in:
lib/dato/local/field_type/file.rb

Direct Known Subclasses

Image

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, format, size) ⇒ File

Returns a new instance of File.



18
19
20
21
22
# File 'lib/dato/local/field_type/file.rb', line 18

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

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



8
9
10
# File 'lib/dato/local/field_type/file.rb', line 8

def format
  @format
end

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/dato/local/field_type/file.rb', line 8

def path
  @path
end

#sizeObject (readonly)

Returns the value of attribute size.



8
9
10
# File 'lib/dato/local/field_type/file.rb', line 8

def size
  @size
end

Class Method Details

.parse(value, _repo) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/dato/local/field_type/file.rb', line 10

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

Instance Method Details

#fileObject



24
25
26
27
28
29
# File 'lib/dato/local/field_type/file.rb', line 24

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

#url(*args) ⇒ Object



31
32
33
# File 'lib/dato/local/field_type/file.rb', line 31

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