Class: IIIFManifest::V3::ManifestBuilder::ContentBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/iiif_manifest/v3/manifest_builder/content_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_factoryObject (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_contentObject (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_factoryObject (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