Class: SmartImage::RatioCalculator::Size

Inherits:
Struct
  • Object
show all
Defined in:
lib/smart_image/ratio_calculator.rb

Overview

Struct to hold the resulting size and compute aspect ratios

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(width, height) ⇒ Size

Returns a new instance of Size.



35
36
37
38
39
# File 'lib/smart_image/ratio_calculator.rb', line 35

def initialize(width, height)
  width, height = Integer(width), Integer(height)
  aspect_ratio = width.to_f / height      
  super(width, height, aspect_ratio)
end

Instance Attribute Details

#aspect_ratioObject

Returns the value of attribute aspect_ratio

Returns:

  • (Object)

    the current value of aspect_ratio



34
35
36
# File 'lib/smart_image/ratio_calculator.rb', line 34

def aspect_ratio
  @aspect_ratio
end

#heightObject

Returns the value of attribute height

Returns:

  • (Object)

    the current value of height



34
35
36
# File 'lib/smart_image/ratio_calculator.rb', line 34

def height
  @height
end

#widthObject

Returns the value of attribute width

Returns:

  • (Object)

    the current value of width



34
35
36
# File 'lib/smart_image/ratio_calculator.rb', line 34

def width
  @width
end