Class: Dato::Local::FieldType::Image

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

Instance Attribute Summary collapse

Attributes inherited from File

#format, #path, #size

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from File

#file, #url

Constructor Details

#initialize(path, format, size, width, height, alt, title, imgix_host) ⇒ Image

Returns a new instance of Image.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/dato/local/field_type/image.rb', line 23

def initialize(
  path,
  format,
  size,
  width,
  height,
  alt,
  title,
  imgix_host
)
  super(path, format, size, imgix_host)
  @width = width
  @height = height
  @alt = alt
  @title = title
end

Instance Attribute Details

#altObject (readonly)

Returns the value of attribute alt.



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

def alt
  @alt
end

#heightObject (readonly)

Returns the value of attribute height.



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

def height
  @height
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

#widthObject (readonly)

Returns the value of attribute width.



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

def width
  @width
end

Class Method Details

.parse(value, repo) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/dato/local/field_type/image.rb', line 10

def self.parse(value, repo)
  value && new(
    value[:path],
    value[:format],
    value[:size],
    value[:width],
    value[:height],
    value[:alt],
    value[:title],
    repo.site.entity.imgix_host
  )
end

Instance Method Details

#to_hash(*args) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/dato/local/field_type/image.rb', line 40

def to_hash(*args)
  super.merge(
    width: width,
    height: height,
    alt: alt,
    title: title
  )
end