Class: IIIFManifest::ManifestBuilder::StructureBuilder

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

Direct Known Subclasses

V3::ManifestBuilder::StructureBuilder

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record, canvas_builder_factory:, iiif_range_factory:) ⇒ StructureBuilder

Returns a new instance of StructureBuilder.



5
6
7
8
9
# File 'lib/iiif_manifest/manifest_builder/structure_builder.rb', line 5

def initialize(record, canvas_builder_factory:, iiif_range_factory:)
  @record = record
  @canvas_builder_factory = canvas_builder_factory
  @iiif_range_factory = iiif_range_factory
end

Instance Attribute Details

#canvas_builder_factoryObject (readonly)

Returns the value of attribute canvas_builder_factory.



4
5
6
# File 'lib/iiif_manifest/manifest_builder/structure_builder.rb', line 4

def canvas_builder_factory
  @canvas_builder_factory
end

#iiif_range_factoryObject (readonly)

Returns the value of attribute iiif_range_factory.



4
5
6
# File 'lib/iiif_manifest/manifest_builder/structure_builder.rb', line 4

def iiif_range_factory
  @iiif_range_factory
end

#recordObject (readonly)

Returns the value of attribute record.



4
5
6
# File 'lib/iiif_manifest/manifest_builder/structure_builder.rb', line 4

def record
  @record
end

Instance Method Details

#apply(manifest) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/iiif_manifest/manifest_builder/structure_builder.rb', line 11

def apply(manifest)
  top_ranges.each do |top_range|
    manifest['structures'] ||= []
    manifest['structures'] = range_builder(top_range).apply(manifest['structures'])
  end
  manifest
end

#range_builder(top_range) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/iiif_manifest/manifest_builder/structure_builder.rb', line 19

def range_builder(top_range)
  RangeBuilder.new(
    top_range,
    record, true,
    canvas_builder_factory: canvas_builder_factory,
    iiif_range_factory: iiif_range_factory
  )
end

#top_rangesObject



28
29
30
# File 'lib/iiif_manifest/manifest_builder/structure_builder.rb', line 28

def top_ranges
  record.try(:ranges) || []
end