class IiifS3::ImageRecord

Class ImageRecord provides a data structure for a single image file. It contains information for content from the manifest level down to the specific variants of the images.

It has the concept of primary images, which are the first (or only) image in the sequence. This is the image where much of the top-level metadata is taken from. Each sequence can only have a single primary image, but that constraint in enforced

@author David Newbury <david.newbury@gmail.com>

Attributes

attribution[RW]
description[RW]
id[RW]
is_document[W]
label[RW]
license[RW]
metadata[RW]
page_number[W]
section[W]
section_label[W]
variants[RW]

Public Class Methods

new(opts={}) click to toggle source

@param [Hash] opts @option opts [String] :id The primary ID for the object. @option opts [String] :label The human-readable label for all grouped records @option opts [String] :description A longer, human-readable description of the gropued records @option opts [String] :logo A URL pointing to a logo of the institution @option opts [Hash] :variants A hash of derivative names and sizes

@example {thumb: 150}
# File lib/iiif_s3/image_record.rb, line 36
def initialize(opts={})
  opts.each do |key, val|
    self.send("#{key}=",val) if self.methods.include? "#{key}=".to_sym
  end
end

Public Instance Methods

image_path() click to toggle source

The path to this image.

@return [String]

# File lib/iiif_s3/image_record.rb, line 52
def image_path
  @path
end
is_document() click to toggle source

Is this image part of a document, or is it a standalone image (or image sequence)?

Currently, the only effects the page viewing hint for the image sequence.

This will only have an effect on the primary image for this sequence.

@return [Bool]

# File lib/iiif_s3/image_record.rb, line 68
def is_document
  return !!@is_document
end
Also aliased as: is_document?
is_document?()
Alias for: is_document
is_master()
Alias for: is_primary
is_primary() click to toggle source

Is this image the master image for its sequence?

Each image sequence has a single image chosen as the primary image for the sequence. By default, page one is the master image, but another image could be chosen as the master if desired.

This is, for instance, the image whose thumbnail is the representation for the entire sequence, and it defined viewing direction and other top-level metadata.

@return [Bool]

# File lib/iiif_s3/image_record.rb, line 119
def is_primary
  if @is_primary.nil?
    self.page_number == 1
  else
    @is_primary
  end
end
Also aliased as: is_primary?, is_master
is_primary=(val) click to toggle source

Set this image record as the master record for the sequence

@param [Bool] val Is this image the master

@return [Bool]

# File lib/iiif_s3/image_record.rb, line 137
def is_primary=(val)
  @is_primary = !!val
end
is_primary?()
Alias for: is_primary
page_number() click to toggle source

The page number of this image. Defaults to 1.

@return [Number]

# File lib/iiif_s3/image_record.rb, line 45
def page_number
  @page_number || 1
end
path=(_path) click to toggle source
# File lib/iiif_s3/image_record.rb, line 56
def path=(_path)
  raise IiifS3::Error::InvalidImageData, "Path is invalid: '#{_path}'" unless _path && File.exist?(_path)
  @path = _path
end
section() click to toggle source

The name of the section this image is contained in.

Currently used to id the canvas for this image.

defaults to IiifS3::DEFAULT_CANVAS_LABEL

@return [String]

# File lib/iiif_s3/image_record.rb, line 80
def section
  @section || DEFAULT_CANVAS_LABEL
end
section_label() click to toggle source

The label for the section this image is contained in.

Currently used to label the canvas for this image.

defaults to IiifS3::DEFAULT_CANVAS_LABEL

@return [String]

# File lib/iiif_s3/image_record.rb, line 91
def section_label
  @section_label || DEFAULT_CANVAS_LABEL
end
viewing_direction() click to toggle source

@return [String] The prefered viewing direction for this image.

Will default to IiifS3::DEFAULT_VIEWING_DIRECTION
# File lib/iiif_s3/image_record.rb, line 98
def viewing_direction
  @viewing_direction || DEFAULT_VIEWING_DIRECTION
end
viewing_direction=(dir) click to toggle source
# File lib/iiif_s3/image_record.rb, line 102
def viewing_direction=(dir)
  raise Error::InvalidViewingDirection unless IiifS3.is_valid_viewing_direction(dir)
  @viewing_direction = dir  
end