Class: Riiif::ImageInformation
- Inherits:
-
IIIF::Image::Dimension
- Object
- IIIF::Image::Dimension
- Riiif::ImageInformation
- Extended by:
- Deprecation
- 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
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(*args) ⇒ 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(*args) ⇒ ImageInformation
Returns a new instance of ImageInformation.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/models/riiif/image_information.rb', line 6 def initialize(*args) if args.size == 2 Deprecation.warn(self, 'calling initialize without kwargs is deprecated. Use named parameters.') super(width: args.first, height: args.second) else @width = args.first[:width] @height = args.first[:height] @format = args.first[:format] @channels = args.first[:channels] end end |
Instance Attribute Details
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
17 18 19 |
# File 'app/models/riiif/image_information.rb', line 17 def channels @channels end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
17 18 19 |
# File 'app/models/riiif/image_information.rb', line 17 def format @format end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
17 18 19 |
# File 'app/models/riiif/image_information.rb', line 17 def height @height end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
17 18 19 |
# File 'app/models/riiif/image_information.rb', line 17 def width @width end |
Instance Method Details
#to_h ⇒ Object
19 20 21 |
# File 'app/models/riiif/image_information.rb', line 19 def to_h { width: width, height: height, format: format, channels: channels } 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.
26 27 28 |
# File 'app/models/riiif/image_information.rb', line 26 def valid? width.present? && height.present? end |