Class: Riiif::ImageInformation

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#heightObject (readonly)

Returns the value of attribute height.



9
10
11
# File 'app/models/riiif/image_information.rb', line 9

def height
  @height
end

#widthObject (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_hObject



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.

Returns:

  • (Boolean)


18
19
20
# File 'app/models/riiif/image_information.rb', line 18

def valid?
  width.present? && height.present?
end