Class: WaxIiif::ImageRecord
- Inherits:
-
Object
- Object
- WaxIiif::ImageRecord
- 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
Instance Attribute Summary collapse
-
#attribution ⇒ Object
Returns the value of attribute attribution.
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#is_document ⇒ Object
writeonly
Sets the attribute is_document.
-
#label ⇒ Object
Returns the value of attribute label.
-
#license ⇒ Object
Returns the value of attribute license.
-
#logo ⇒ Object
Returns the value of attribute logo.
-
#manifest_id ⇒ Object
Returns the value of attribute manifest_id.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#section ⇒ String
The name of the section this image is contained in.
-
#section_label ⇒ String
The label for the section this image is contained in.
-
#variants ⇒ Object
Returns the value of attribute variants.
Instance Method Summary collapse
-
#document? ⇒ Bool
Is this image part of a document, or is it a standalone image (or image sequence)?.
-
#image_path ⇒ String
The path to this image.
-
#initialize(opts = {}) ⇒ ImageRecord
constructor
A new instance of ImageRecord.
-
#is_primary=(val) ⇒ Bool
Set this image record as the master record for the sequence.
- #path=(path) ⇒ Object
-
#primary? ⇒ Bool
Is this image the master image for its sequence?.
-
#viewing_direction ⇒ String
The prefered viewing direction for this image.
- #viewing_direction=(dir) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ ImageRecord
Returns a new instance of ImageRecord.
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
#attribution ⇒ Object
Returns the value of attribute attribution.
18 19 20 |
# File 'lib/wax_iiif/image_record.rb', line 18 def attribution @attribution end |
#description ⇒ Object
Returns the value of attribute description.
17 18 19 |
# File 'lib/wax_iiif/image_record.rb', line 17 def description @description end |
#id ⇒ Object
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
27 28 29 |
# File 'lib/wax_iiif/image_record.rb', line 27 def is_document=(value) @is_document = value end |
#label ⇒ Object
Returns the value of attribute label.
16 17 18 |
# File 'lib/wax_iiif/image_record.rb', line 16 def label @label end |
#license ⇒ Object
Returns the value of attribute license.
19 20 21 |
# File 'lib/wax_iiif/image_record.rb', line 19 def license @license end |
#logo ⇒ Object
Returns the value of attribute logo.
22 23 24 |
# File 'lib/wax_iiif/image_record.rb', line 22 def logo @logo end |
#manifest_id ⇒ Object
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 |
#metadata ⇒ Object
Returns the value of attribute metadata.
20 21 22 |
# File 'lib/wax_iiif/image_record.rb', line 20 def @metadata end |
#section ⇒ String
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
62 63 64 |
# File 'lib/wax_iiif/image_record.rb', line 62 def section @section || DEFAULT_CANVAS_LABEL end |
#section_label ⇒ String
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
73 74 75 |
# File 'lib/wax_iiif/image_record.rb', line 73 def section_label @section_label || DEFAULT_CANVAS_LABEL end |
#variants ⇒ Object
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.
96 97 98 |
# File 'lib/wax_iiif/image_record.rb', line 96 def document? !!@is_document end |
#image_path ⇒ String
The path to this image.
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
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.
112 113 114 |
# File 'lib/wax_iiif/image_record.rb', line 112 def primary? !!@is_primary end |
#viewing_direction ⇒ String
Returns 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 |