Class: Jekyll::SrcsetTag::Image::Instance

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll/srcset_tag/image/instance.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(width:, height:, extension:, image:) ⇒ Instance

Returns a new instance of Instance.



8
9
10
11
12
13
14
15
16
# File 'lib/jekyll/srcset_tag/image/instance.rb', line 8

def initialize(width:, height:, extension:, image:)
  @width = width
  @height = height
  @extension = extension
  @image = image
  @image_width = image[:width].to_i
  @image_height = image[:height].to_i
  calculate_output_dimensions!        
end

Instance Attribute Details

#extensionObject (readonly)

Returns the value of attribute extension.



5
6
7
# File 'lib/jekyll/srcset_tag/image/instance.rb', line 5

def extension
  @extension
end

#heightObject (readonly)

Returns the value of attribute height.



5
6
7
# File 'lib/jekyll/srcset_tag/image/instance.rb', line 5

def height
  @height
end

#imageObject (readonly)

Returns the value of attribute image.



5
6
7
# File 'lib/jekyll/srcset_tag/image/instance.rb', line 5

def image
  @image
end

#image_heightObject (readonly)

Returns the value of attribute image_height.



5
6
7
# File 'lib/jekyll/srcset_tag/image/instance.rb', line 5

def image_height
  @image_height
end

#image_widthObject (readonly)

Returns the value of attribute image_width.



5
6
7
# File 'lib/jekyll/srcset_tag/image/instance.rb', line 5

def image_width
  @image_width
end

#output_heightObject (readonly)

Returns the value of attribute output_height.



5
6
7
# File 'lib/jekyll/srcset_tag/image/instance.rb', line 5

def output_height
  @output_height
end

#output_widthObject (readonly)

Returns the value of attribute output_width.



5
6
7
# File 'lib/jekyll/srcset_tag/image/instance.rb', line 5

def output_width
  @output_width
end

#undersizedObject (readonly)

Returns the value of attribute undersized.



5
6
7
# File 'lib/jekyll/srcset_tag/image/instance.rb', line 5

def undersized
  @undersized
end

#widthObject (readonly)

Returns the value of attribute width.



5
6
7
# File 'lib/jekyll/srcset_tag/image/instance.rb', line 5

def width
  @width
end

Instance Method Details

#filenameObject



18
19
20
# File 'lib/jekyll/srcset_tag/image/instance.rb', line 18

def filename
  output_width.to_s + 'x' + output_height.to_s + extension
end

#undersized?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/jekyll/srcset_tag/image/instance.rb', line 22

def undersized?
  @undersized
end