Class: IIIFManifest::V3::ManifestBuilder::ContentBuilder
- Inherits:
-
Object
- Object
- IIIFManifest::V3::ManifestBuilder::ContentBuilder
- Defined in:
- lib/iiif_manifest/v3/manifest_builder/content_builder.rb
Instance Attribute Summary collapse
-
#body_builder_factory ⇒ Object
readonly
Returns the value of attribute body_builder_factory.
-
#display_content ⇒ Object
readonly
Returns the value of attribute display_content.
-
#iiif_annotation_factory ⇒ Object
readonly
Returns the value of attribute iiif_annotation_factory.
Instance Method Summary collapse
- #apply(canvas) ⇒ Object
-
#initialize(display_content, iiif_annotation_factory:, body_builder_factory:) ⇒ ContentBuilder
constructor
A new instance of ContentBuilder.
Constructor Details
#initialize(display_content, iiif_annotation_factory:, body_builder_factory:) ⇒ ContentBuilder
Returns a new instance of ContentBuilder.
6 7 8 9 10 11 |
# File 'lib/iiif_manifest/v3/manifest_builder/content_builder.rb', line 6 def initialize(display_content, iiif_annotation_factory:, body_builder_factory:) @display_content = display_content @iiif_annotation_factory = iiif_annotation_factory @body_builder_factory = body_builder_factory build_resource end |
Instance Attribute Details
#body_builder_factory ⇒ Object (readonly)
Returns the value of attribute body_builder_factory.
5 6 7 |
# File 'lib/iiif_manifest/v3/manifest_builder/content_builder.rb', line 5 def body_builder_factory @body_builder_factory end |
#display_content ⇒ Object (readonly)
Returns the value of attribute display_content.
5 6 7 |
# File 'lib/iiif_manifest/v3/manifest_builder/content_builder.rb', line 5 def display_content @display_content end |
#iiif_annotation_factory ⇒ Object (readonly)
Returns the value of attribute iiif_annotation_factory.
5 6 7 |
# File 'lib/iiif_manifest/v3/manifest_builder/content_builder.rb', line 5 def iiif_annotation_factory @iiif_annotation_factory end |
Instance Method Details
#apply(canvas) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/iiif_manifest/v3/manifest_builder/content_builder.rb', line 13 def apply(canvas) # Assume first item in canvas is an annotation page annotation['id'] = "#{canvas.items.first['id']}/annotation/#{annotation.index}" annotation['target'] = canvas['id'] canvas['width'] = annotation.body['width'] if annotation.body['width'].present? canvas['height'] = annotation.body['height'] if annotation.body['height'].present? canvas['duration'] = annotation.body['duration'] if annotation.body['duration'].present? canvas.items.first.items += [annotation] end |