Class: IIIFManifest::V3::ManifestBuilder::CanvasBuilder

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record, parent, iiif_canvas_factory:, content_builder:, choice_builder:, annotation_content_builder:, iiif_annotation_page_factory:, thumbnail_builder_factory:, placeholder_canvas_builder_factory:) ⇒ CanvasBuilder

Returns a new instance of CanvasBuilder.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/iiif_manifest/v3/manifest_builder/canvas_builder.rb', line 9

def initialize(record,
               parent,
               iiif_canvas_factory:,
               content_builder:,
               choice_builder:,
               annotation_content_builder:,
               iiif_annotation_page_factory:,
               thumbnail_builder_factory:,
               placeholder_canvas_builder_factory:)
  @record = record
  @parent = parent
  @iiif_canvas_factory = iiif_canvas_factory
  @content_builder = content_builder
  @choice_builder = choice_builder
  @annotation_content_builder = annotation_content_builder
  @iiif_annotation_page_factory = iiif_annotation_page_factory
  @thumbnail_builder_factory = thumbnail_builder_factory
  @placeholder_canvas_builder_factory = placeholder_canvas_builder_factory
  apply_record_properties
  # Presentation 2.x approach
  attach_image if display_image
  # Presentation 3.0 approach
  attach_content if display_content
  attach_annotation if annotation_content
  attach_placeholder_canvas if placeholder_content
end

Instance Attribute Details

#annotation_content_builderObject (readonly)

Returns the value of attribute annotation_content_builder.



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

def annotation_content_builder
  @annotation_content_builder
end

#choice_builderObject (readonly)

Returns the value of attribute choice_builder.



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

def choice_builder
  @choice_builder
end

#content_builderObject (readonly)

Returns the value of attribute content_builder.



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

def content_builder
  @content_builder
end

#iiif_annotation_page_factoryObject (readonly)

Returns the value of attribute iiif_annotation_page_factory.



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

def iiif_annotation_page_factory
  @iiif_annotation_page_factory
end

#iiif_canvas_factoryObject (readonly)

Returns the value of attribute iiif_canvas_factory.



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

def iiif_canvas_factory
  @iiif_canvas_factory
end

#parentObject (readonly)

Returns the value of attribute parent.



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

def parent
  @parent
end

#placeholder_canvas_builder_factoryObject (readonly)

Returns the value of attribute placeholder_canvas_builder_factory.



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

def placeholder_canvas_builder_factory
  @placeholder_canvas_builder_factory
end

#recordObject (readonly)

Returns the value of attribute record.



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

def record
  @record
end

#thumbnail_builder_factoryObject (readonly)

Returns the value of attribute thumbnail_builder_factory.



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

def thumbnail_builder_factory
  @thumbnail_builder_factory
end

Instance Method Details

#apply(items) ⇒ Object



46
47
48
49
# File 'lib/iiif_manifest/v3/manifest_builder/canvas_builder.rb', line 46

def apply(items)
  return items if canvas.items.blank?
  items << canvas
end

#canvasObject



36
37
38
# File 'lib/iiif_manifest/v3/manifest_builder/canvas_builder.rb', line 36

def canvas
  @canvas ||= iiif_canvas_factory.new
end

#pathObject



40
41
42
43
44
# File 'lib/iiif_manifest/v3/manifest_builder/canvas_builder.rb', line 40

def path
  path = "#{parent.manifest_url}/canvas/#{record.id}"
  path << "##{record.media_fragment}" if record.respond_to?(:media_fragment) && record.media_fragment.present?
  path
end