Class: Riiif::ImageInformation

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

Instance Method Summary collapse

Constructor Details

#initialize(width, height) ⇒ ImageInformation

Returns a new instance of ImageInformation.



6
7
8
9
# File 'app/models/riiif/image_information.rb', line 6

def initialize(width, height)
  @width = width
  @height = height
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



11
12
13
# File 'app/models/riiif/image_information.rb', line 11

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width.



11
12
13
# File 'app/models/riiif/image_information.rb', line 11

def width
  @width
end

Instance Method Details

#==(other) ⇒ Object



31
32
33
34
35
# File 'app/models/riiif/image_information.rb', line 31

def ==(other)
  other.class == self.class &&
    other.width == width &&
    other.height == height
end

#[](key) ⇒ Object



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

def [](key)
  to_h[key]
end

#to_hObject



13
14
15
# File 'app/models/riiif/image_information.rb', line 13

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)


27
28
29
# File 'app/models/riiif/image_information.rb', line 27

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