Class: IIIFManifest::V3::ManifestBuilder
- Inherits:
-
Object
- Object
- IIIFManifest::V3::ManifestBuilder
- Defined in:
- lib/iiif_manifest/v3/manifest_builder.rb,
lib/iiif_manifest/v3/manifest_builder/body_builder.rb,
lib/iiif_manifest/v3/manifest_builder/iiif_service.rb,
lib/iiif_manifest/v3/manifest_builder/canvas_builder.rb,
lib/iiif_manifest/v3/manifest_builder/choice_builder.rb,
lib/iiif_manifest/v3/manifest_builder/content_builder.rb,
lib/iiif_manifest/v3/manifest_builder/structure_builder.rb,
lib/iiif_manifest/v3/manifest_builder/image_service_builder.rb,
lib/iiif_manifest/v3/manifest_builder/record_property_builder.rb
Defined Under Namespace
Classes: BodyBuilder, CanvasBuilder, ChoiceBuilder, ContentBuilder, IIIFManifest, IIIFService, ImageServiceBuilder, RangeBuilder, RecordPropertyBuilder, StructureBuilder
Instance Attribute Summary collapse
-
#builders ⇒ Object
readonly
Returns the value of attribute builders.
-
#top_record_factory ⇒ Object
readonly
Returns the value of attribute top_record_factory.
-
#work ⇒ Object
readonly
Returns the value of attribute work.
Class Method Summary collapse
-
.language_map(obj) ⇒ Object
Utility method to wrap the obj into a IIIF V3 compliant language map as needed.
- .valid_language_map?(obj) ⇒ Boolean
Instance Method Summary collapse
- #apply(collection) ⇒ Object
-
#initialize(work, builders:, top_record_factory:) ⇒ ManifestBuilder
constructor
A new instance of ManifestBuilder.
- #to_h ⇒ Object
Constructor Details
#initialize(work, builders:, top_record_factory:) ⇒ ManifestBuilder
Returns a new instance of ManifestBuilder.
38 39 40 41 42 |
# File 'lib/iiif_manifest/v3/manifest_builder.rb', line 38 def initialize(work, builders:, top_record_factory:) @work = work @builders = builders @top_record_factory = top_record_factory end |
Instance Attribute Details
#builders ⇒ Object (readonly)
Returns the value of attribute builders.
35 36 37 |
# File 'lib/iiif_manifest/v3/manifest_builder.rb', line 35 def builders @builders end |
#top_record_factory ⇒ Object (readonly)
Returns the value of attribute top_record_factory.
35 36 37 |
# File 'lib/iiif_manifest/v3/manifest_builder.rb', line 35 def top_record_factory @top_record_factory end |
#work ⇒ Object (readonly)
Returns the value of attribute work.
35 36 37 |
# File 'lib/iiif_manifest/v3/manifest_builder.rb', line 35 def work @work end |
Class Method Details
.language_map(obj) ⇒ Object
Utility method to wrap the obj into a IIIF V3 compliant language map as needed.
15 16 17 18 19 |
# File 'lib/iiif_manifest/v3/manifest_builder.rb', line 15 def language_map(obj) return nil if obj.blank? return obj if valid_language_map?(obj) obj_to_language_map(obj) end |
.valid_language_map?(obj) ⇒ Boolean
21 22 23 24 25 |
# File 'lib/iiif_manifest/v3/manifest_builder.rb', line 21 def valid_language_map?(obj) obj.is_a?(Hash) && obj.all? do |k, v| k.is_a?(String) && v.is_a?(Array) && v.all? { |o| o.is_a?(String) } end end |
Instance Method Details
#apply(collection) ⇒ Object
44 45 46 47 48 |
# File 'lib/iiif_manifest/v3/manifest_builder.rb', line 44 def apply(collection) collection['manifests'] ||= [] collection['manifests'] << to_h collection end |
#to_h ⇒ Object
50 51 52 |
# File 'lib/iiif_manifest/v3/manifest_builder.rb', line 50 def to_h @to_h ||= builders.new(work).apply(top_record) end |