Class: IIIFManifest::V3::ManifestBuilder::ChoiceBuilder

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(display_content, iiif_annotation_factory:, body_builder_factory:, iiif_choice_factory:) ⇒ ChoiceBuilder

Returns a new instance of ChoiceBuilder.



6
7
8
9
10
11
12
# File 'lib/iiif_manifest/v3/manifest_builder/choice_builder.rb', line 6

def initialize(display_content, iiif_annotation_factory:, body_builder_factory:, iiif_choice_factory:)
  @display_content = display_content
  @iiif_annotation_factory = iiif_annotation_factory
  @body_builder_factory = body_builder_factory
  @iiif_choice_factory = iiif_choice_factory
  build_choice
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/choice_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/choice_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/choice_builder.rb', line 5

def iiif_annotation_factory
  @iiif_annotation_factory
end

#iiif_choice_factoryObject (readonly)

Returns the value of attribute iiif_choice_factory.



5
6
7
# File 'lib/iiif_manifest/v3/manifest_builder/choice_builder.rb', line 5

def iiif_choice_factory
  @iiif_choice_factory
end

Instance Method Details

#apply(canvas) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/iiif_manifest/v3/manifest_builder/choice_builder.rb', line 14

def apply(canvas)
  annotation['target'] = canvas['id']
  canvas['width'] = choice.items.first['width']
  canvas['height'] = choice.items.first['height']
  canvas['duration'] = choice.items.first['duration']
  annotation.body = choice
  # Assume first item in canvas is an annotation page
  canvas.items.first.items += [annotation]
end