Class: IIIF::Image::Size::Width

Inherits:
Object
  • Object
show all
Defined in:
lib/iiif/image/size/width.rb

Overview

The image or region should be scaled so that its width is exactly equal to the provided parameter, and the height will be a calculated value that maintains the aspect ratio of the extracted region

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(width) ⇒ Width

Returns a new instance of Width.

Parameters:

  • width (Integer)


8
9
10
# File 'lib/iiif/image/size/width.rb', line 8

def initialize(width)
  @width = width
end

Instance Attribute Details

#widthObject (readonly)

Returns the value of attribute width.



12
13
14
# File 'lib/iiif/image/size/width.rb', line 12

def width
  @width
end

Instance Method Details

#height_for_aspect_ratio(ratio) ⇒ Object

Parameters:

  • ratio (Rational)

    the aspect ratio



15
16
17
# File 'lib/iiif/image/size/width.rb', line 15

def height_for_aspect_ratio(ratio)
  (width / ratio).round
end

#to_sObject



19
20
21
# File 'lib/iiif/image/size/width.rb', line 19

def to_s
  "#{width},"
end