Sha256: 8ca827889aa119033cb8aea6bf098b84c9df0c15d414571b7b9dc47ee795078e

Contents?: true

Size: 1002 Bytes

Versions: 8

Compression:

Stored size: 1002 Bytes

Contents

module Riiif
  # This is the result of calling the Riiif.image_info service. It stores the height & width
  class ImageInformation < IIIF::Image::Dimension
    extend Deprecation

    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
    attr_reader :format, :height, :width, :channels

    def to_h
      { width: width, height: height, format: format, channels: channels }
    end

    # 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.
    def valid?
      width.present? && height.present?
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
riiif-2.7.0 app/models/riiif/image_information.rb
riiif-2.6.0 app/models/riiif/image_information.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/riiif-2.5.0/app/models/riiif/image_information.rb
riiif-2.5.0 app/models/riiif/image_information.rb
riiif-2.4.0 app/models/riiif/image_information.rb
riiif-2.3.0 app/models/riiif/image_information.rb
riiif-2.2.0 app/models/riiif/image_information.rb
riiif-2.1.0 app/models/riiif/image_information.rb