Class: IIIFManifest::V3::ManifestBuilder::RecordPropertyBuilder

Inherits:
ManifestBuilder::RecordPropertyBuilder show all
Defined in:
lib/iiif_manifest/v3/manifest_builder/record_property_builder.rb

Instance Attribute Summary collapse

Attributes inherited from ManifestBuilder::RecordPropertyBuilder

#iiif_autocomplete_service_factory, #iiif_search_service_factory, #record

Instance Method Summary collapse

Constructor Details

#initialize(record, iiif_search_service_factory:, iiif_autocomplete_service_factory:, canvas_builder_factory:, thumbnail_builder_factory:) ⇒ RecordPropertyBuilder

Returns a new instance of RecordPropertyBuilder.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/iiif_manifest/v3/manifest_builder/record_property_builder.rb', line 6

def initialize(record,
               iiif_search_service_factory:,
               iiif_autocomplete_service_factory:,
               canvas_builder_factory:,
               thumbnail_builder_factory:)
  super(record,
        iiif_search_service_factory: iiif_search_service_factory,
        iiif_autocomplete_service_factory: iiif_autocomplete_service_factory)
  @canvas_builder_factory = canvas_builder_factory
  @thumbnail_builder_factory = thumbnail_builder_factory
end

Instance Attribute Details

#canvas_builder_factoryObject (readonly)

Returns the value of attribute canvas_builder_factory.



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

def canvas_builder_factory
  @canvas_builder_factory
end

#thumbnail_builder_factoryObject (readonly)

Returns the value of attribute thumbnail_builder_factory.



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

def thumbnail_builder_factory
  @thumbnail_builder_factory
end

Instance Method Details

#apply(manifest) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/iiif_manifest/v3/manifest_builder/record_property_builder.rb', line 18

def apply(manifest)
  setup_manifest_from_record(manifest, record)
  # Build the items array
  canvas_builder.apply(manifest.items)
  apply_thumbnail_to(manifest) unless manifest_thumbnail?
  manifest
end

#populate_renderingObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/iiif_manifest/v3/manifest_builder/record_property_builder.rb', line 26

def populate_rendering
  return unless record.respond_to?(:sequence_rendering)
  record.sequence_rendering.collect do |rendering|
    sequence_rendering = rendering.to_h.except('@id', 'label')
    sequence_rendering['id'] = rendering['@id']
    if rendering['label'].present?
      sequence_rendering['label'] = ManifestBuilder.language_map(rendering['label'])
    end
    sequence_rendering
  end
end