Class: IIIFManifest::V3::ManifestBuilder::AnnotationContentBuilder

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(annotation_content, iiif_annotation_factory:, body_builder_factory:) ⇒ AnnotationContentBuilder

Returns a new instance of AnnotationContentBuilder.



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

def initialize(annotation_content, iiif_annotation_factory:, body_builder_factory:)
  @annotation_content = annotation_content
  @iiif_annotation_factory = iiif_annotation_factory
  @body_builder_factory = body_builder_factory
  build_annotation_resource
end

Instance Attribute Details

#annotation_contentObject (readonly)

Returns the value of attribute annotation_content.



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

def annotation_content
  @annotation_content
end

#body_builder_factoryObject (readonly)

Returns the value of attribute body_builder_factory.



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

def body_builder_factory
  @body_builder_factory
end

#iiif_annotation_factoryObject (readonly)

Returns the value of attribute iiif_annotation_factory.



5
6
7
# File 'lib/iiif_manifest/v3/manifest_builder/annotation_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
# File 'lib/iiif_manifest/v3/manifest_builder/annotation_content_builder.rb', line 13

def apply(canvas)
  # Assume first item in canvas annotations is an annotation page
  canvas_id = canvas.annotations.first['id']
  generic_annotation['id'] = annotation_id(canvas_id)
  generic_annotation['target'] = target(canvas)
  generic_annotation['motivation'] = motivation
  generic_annotation
end