Class: Riiif::ImageInformation

Inherits:
IIIF::Image::Dimension
  • 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(*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

#channelsObject (readonly)

Returns the value of attribute channels.



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

def channels
  @channels
end

#formatObject (readonly)

Returns the value of attribute format.



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

def format
  @format
end

#heightObject (readonly)

Returns the value of attribute height.



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

def height
  @height
end

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



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.

Returns:

  • (Boolean)


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

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