Class: Riiif::ImageInformation
- Inherits:
-
Object
- Object
- Riiif::ImageInformation
- Defined in:
- app/models/riiif/image_information.rb
Overview
This is the result of calling the Riiif.image_info service. It stores the height & width
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
-
#initialize(width, height) ⇒ ImageInformation
constructor
A new instance of ImageInformation.
- #to_h ⇒ Object
-
#valid? ⇒ Boolean
Image information is only valid if height and width are present.
Constructor Details
#initialize(width, height) ⇒ ImageInformation
Returns a new instance of ImageInformation.
4 5 6 7 |
# File 'app/models/riiif/image_information.rb', line 4 def initialize(width, height) @width = width @height = height end |
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height.
9 10 11 |
# File 'app/models/riiif/image_information.rb', line 9 def height @height end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
9 10 11 |
# File 'app/models/riiif/image_information.rb', line 9 def width @width end |
Instance Method Details
#==(other) ⇒ Object
22 23 24 25 26 |
# File 'app/models/riiif/image_information.rb', line 22 def ==(other) other.class == self.class && other.width == width && other.height == height end |
#to_h ⇒ Object
11 12 13 |
# File 'app/models/riiif/image_information.rb', line 11 def to_h { width: width, height: height } end |
#valid? ⇒ Boolean
Image information is only valid if height and width are present. If an image info service doesn’t have the value yet (not characterized perhaps?) then we wouldn’t want to cache this value.
18 19 20 |
# File 'app/models/riiif/image_information.rb', line 18 def valid? width.present? && height.present? end |