Class: IIIF::Image::Dimension
- Inherits:
-
Object
- Object
- IIIF::Image::Dimension
- Defined in:
- lib/iiif/image/models/dimension.rb
Overview
Represents the size of a rectangle
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #aspect ⇒ Object
-
#enclosed_by?(other) ⇒ Boolean
Return true if both dimensions of other are greater.
-
#initialize(height:, width:) ⇒ Dimension
constructor
A new instance of Dimension.
- #scale(scale) ⇒ Dimension
Constructor Details
#initialize(height:, width:) ⇒ Dimension
Returns a new instance of Dimension.
4 5 6 7 |
# File 'lib/iiif/image/models/dimension.rb', line 4 def initialize(height:, width:) @height = height @width = width end |
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height.
9 10 11 |
# File 'lib/iiif/image/models/dimension.rb', line 9 def height @height end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
9 10 11 |
# File 'lib/iiif/image/models/dimension.rb', line 9 def width @width end |
Instance Method Details
#==(other) ⇒ Object
22 23 24 |
# File 'lib/iiif/image/models/dimension.rb', line 22 def ==(other) width == other.width && height == other.height end |
#aspect ⇒ Object
26 27 28 |
# File 'lib/iiif/image/models/dimension.rb', line 26 def aspect Rational(width, height) end |
#enclosed_by?(other) ⇒ Boolean
Return true if both dimensions of other are greater
18 19 20 |
# File 'lib/iiif/image/models/dimension.rb', line 18 def enclosed_by?(other) width <= other.width && height <= other.height end |