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/thumbnail_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, ThumbnailBuilder
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.
39 40 41 42 43 |
# File 'lib/iiif_manifest/v3/manifest_builder.rb', line 39 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.
36 37 38 |
# File 'lib/iiif_manifest/v3/manifest_builder.rb', line 36 def builders @builders end |
#top_record_factory ⇒ Object (readonly)
Returns the value of attribute top_record_factory.
36 37 38 |
# File 'lib/iiif_manifest/v3/manifest_builder.rb', line 36 def top_record_factory @top_record_factory end |
#work ⇒ Object (readonly)
Returns the value of attribute work.
36 37 38 |
# File 'lib/iiif_manifest/v3/manifest_builder.rb', line 36 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.
16 17 18 19 20 |
# File 'lib/iiif_manifest/v3/manifest_builder.rb', line 16 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
22 23 24 25 26 |
# File 'lib/iiif_manifest/v3/manifest_builder.rb', line 22 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
45 46 47 48 49 |
# File 'lib/iiif_manifest/v3/manifest_builder.rb', line 45 def apply(collection) collection['manifests'] ||= [] collection['manifests'] << to_h collection end |
#to_h ⇒ Object
51 52 53 |
# File 'lib/iiif_manifest/v3/manifest_builder.rb', line 51 def to_h @to_h ||= builders.new(work).apply(top_record) end |