Class: IIIFManifest::ManifestBuilder::RangeBuilder
- Inherits:
-
Object
- Object
- IIIFManifest::ManifestBuilder::RangeBuilder
show all
- Defined in:
- lib/iiif_manifest/manifest_builder/structure_builder.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(record, parent, top = false, canvas_builder_factory:, iiif_range_factory:) ⇒ RangeBuilder
Returns a new instance of RangeBuilder.
35
36
37
38
39
40
41
42
|
# File 'lib/iiif_manifest/manifest_builder/structure_builder.rb', line 35
def initialize(record, parent, top = false, canvas_builder_factory:, iiif_range_factory:)
@record = record
@parent = parent
@top = top
@canvas_builder_factory = canvas_builder_factory
@iiif_range_factory = iiif_range_factory
build_range
end
|
Instance Attribute Details
#canvas_builder_factory ⇒ Object
Returns the value of attribute canvas_builder_factory.
33
34
35
|
# File 'lib/iiif_manifest/manifest_builder/structure_builder.rb', line 33
def canvas_builder_factory
@canvas_builder_factory
end
|
#iiif_range_factory ⇒ Object
Returns the value of attribute iiif_range_factory.
33
34
35
|
# File 'lib/iiif_manifest/manifest_builder/structure_builder.rb', line 33
def iiif_range_factory
@iiif_range_factory
end
|
#parent ⇒ Object
Returns the value of attribute parent.
33
34
35
|
# File 'lib/iiif_manifest/manifest_builder/structure_builder.rb', line 33
def parent
@parent
end
|
#record ⇒ Object
Returns the value of attribute record.
33
34
35
|
# File 'lib/iiif_manifest/manifest_builder/structure_builder.rb', line 33
def record
@record
end
|
Instance Method Details
#apply(manifest) ⇒ Object
52
53
54
55
56
57
58
|
# File 'lib/iiif_manifest/manifest_builder/structure_builder.rb', line 52
def apply(manifest)
manifest << range
sub_ranges.map do |sub_range|
manifest = sub_range.apply(manifest)
end
manifest
end
|
#build_range ⇒ Object
60
61
62
63
64
65
66
|
# File 'lib/iiif_manifest/manifest_builder/structure_builder.rb', line 60
def build_range
range['@id'] = path
range['label'] = record.label
range['viewingHint'] = 'top' if top?
range['ranges'] = sub_ranges.map(&:path)
range['canvases'] = canvas_builders.map(&:path)
end
|
#canvas_builders ⇒ Object
79
80
81
82
83
|
# File 'lib/iiif_manifest/manifest_builder/structure_builder.rb', line 79
def canvas_builders
@canvas_builders ||= file_set_presenters.map do |file_set_presenter|
canvas_builder_factory.new(file_set_presenter, parent)
end
end
|
#index ⇒ Object
48
49
50
|
# File 'lib/iiif_manifest/manifest_builder/structure_builder.rb', line 48
def index
@index ||= SecureRandom.uuid
end
|
#path ⇒ Object
44
45
46
|
# File 'lib/iiif_manifest/manifest_builder/structure_builder.rb', line 44
def path
"#{parent.manifest_url}/range/r#{index}"
end
|
#range ⇒ Object
85
86
87
|
# File 'lib/iiif_manifest/manifest_builder/structure_builder.rb', line 85
def range
@range ||= iiif_range_factory.new
end
|
#sub_ranges ⇒ Object
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/iiif_manifest/manifest_builder/structure_builder.rb', line 68
def sub_ranges
@sub_ranges ||= record.ranges.map do |sub_range|
RangeBuilder.new(
sub_range,
parent,
canvas_builder_factory: canvas_builder_factory,
iiif_range_factory: iiif_range_factory
)
end
end
|
#top? ⇒ Boolean
89
90
91
|
# File 'lib/iiif_manifest/manifest_builder/structure_builder.rb', line 89
def top?
@top
end
|