Class: WaxIiif::ImageRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/wax_iiif/image_record.rb

Overview

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 isnt enforced

Author:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ ImageRecord

Returns a new instance of ImageRecord.

Examples:

150

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :label (String)

    The human-readable label for all grouped records

  • :description (String)

    A longer, human-readable description of the gropued records

  • :logo (String)

    A URL pointing to a logo of the institution

  • :variants (Hash)

    A hash of derivative names and sizes



37
38
39
40
41
# File 'lib/wax_iiif/image_record.rb', line 37

def initialize(opts = {})
  opts.each do |key, val|
    self.send("#{key}=", val) if self.methods.include? "#{key}=".to_sym
  end
end

Instance Attribute Details

#attributionObject

Returns the value of attribute attribution.



18
19
20
# File 'lib/wax_iiif/image_record.rb', line 18

def attribution
  @attribution
end

#descriptionObject

Returns the value of attribute description.



17
18
19
# File 'lib/wax_iiif/image_record.rb', line 17

def description
  @description
end

#idObject

Returns the value of attribute id.



15
16
17
# File 'lib/wax_iiif/image_record.rb', line 15

def id
  @id
end

#is_document=(value) ⇒ Object (writeonly)

Sets the attribute is_document

Parameters:

  • value

    the value to set the attribute is_document to.



27
28
29
# File 'lib/wax_iiif/image_record.rb', line 27

def is_document=(value)
  @is_document = value
end

#labelObject

Returns the value of attribute label.



16
17
18
# File 'lib/wax_iiif/image_record.rb', line 16

def label
  @label
end

#licenseObject

Returns the value of attribute license.



19
20
21
# File 'lib/wax_iiif/image_record.rb', line 19

def license
  @license
end

#logoObject

Returns the value of attribute logo.



22
23
24
# File 'lib/wax_iiif/image_record.rb', line 22

def 
  @logo
end

#manifest_idObject

Returns the value of attribute manifest_id.



14
15
16
# File 'lib/wax_iiif/image_record.rb', line 14

def manifest_id
  @manifest_id
end

#metadataObject

Returns the value of attribute metadata.



20
21
22
# File 'lib/wax_iiif/image_record.rb', line 20

def 
  @metadata
end

#sectionString

The name of the section this image is contained in. Currently used to id the canvas for this image.

defaults to WaxIiif::DEFAULT_CANVAS_LABEL

Returns:

  • (String)


62
63
64
# File 'lib/wax_iiif/image_record.rb', line 62

def section
  @section || DEFAULT_CANVAS_LABEL
end

#section_labelString

The label for the section this image is contained in. Currently used to label the canvas for this image.

defaults to WaxIiif::DEFAULT_CANVAS_LABEL

Returns:

  • (String)


73
74
75
# File 'lib/wax_iiif/image_record.rb', line 73

def 
  @section_label || DEFAULT_CANVAS_LABEL
end

#variantsObject

Returns the value of attribute variants.



23
24
25
# File 'lib/wax_iiif/image_record.rb', line 23

def variants
  @variants
end

Instance Method Details

#document?Bool

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.

Returns:

  • (Bool)


96
97
98
# File 'lib/wax_iiif/image_record.rb', line 96

def document?
  !!@is_document
end

#image_pathString

The path to this image.

Returns:

  • (String)


46
47
48
# File 'lib/wax_iiif/image_record.rb', line 46

def image_path
  @path
end

#is_primary=(val) ⇒ Bool

Set this image record as the master record for the sequence

Parameters:

  • val (Bool)

    Is this image the master

Returns:

  • (Bool)


122
123
124
# File 'lib/wax_iiif/image_record.rb', line 122

def is_primary=(val)
  @is_primary = !!val
end

#path=(path) ⇒ Object



50
51
52
53
# File 'lib/wax_iiif/image_record.rb', line 50

def path=(path)
  raise WaxIiif::Error::InvalidImageData, "Path is invalid: '#{path}'" unless path && File.exist?(path)
  @path = path
end

#primary?Bool

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.

Returns:

  • (Bool)


112
113
114
# File 'lib/wax_iiif/image_record.rb', line 112

def primary?
  !!@is_primary
end

#viewing_directionString

Returns The prefered viewing direction for this image. Will default to WaxIiif::DEFAULT_VIEWING_DIRECTION.

Returns:

  • (String)

    The prefered viewing direction for this image. Will default to WaxIiif::DEFAULT_VIEWING_DIRECTION



80
81
82
# File 'lib/wax_iiif/image_record.rb', line 80

def viewing_direction
  @viewing_direction || DEFAULT_VIEWING_DIRECTION
end

#viewing_direction=(dir) ⇒ Object



84
85
86
87
# File 'lib/wax_iiif/image_record.rb', line 84

def viewing_direction=(dir)
  raise Error::InvalidViewingDirection unless WaxIiif.valid_viewing_direction?(dir)
  @viewing_direction = dir
end