Class: WaxIiif::Collection
- Inherits:
-
Object
- Object
- WaxIiif::Collection
- Includes:
- BaseProperties
- Defined in:
- lib/wax_iiif/collection.rb
Overview
Class Collection is an abstraction over the IIIF Collection, which is an aggregation of IIIF manifests.
Constant Summary collapse
- TYPE =
Returns The IIIF Type for collections.
'sc:Collection'.freeze
Instance Attribute Summary collapse
-
#collections ⇒ Object
readonly
Returns the value of attribute collections.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#manifests ⇒ Object
readonly
Returns the value of attribute manifests.
Attributes included from BaseProperties
#attribution, #description, #id, #license, #logo, #metadata, #related
Instance Method Summary collapse
- #add_collection(collection) ⇒ Object
- #add_manifest(manifest) ⇒ Object
-
#initialize(config) ⇒ Collection
constructor
A new instance of Collection.
-
#to_json(*_args) ⇒ String
The JSON representation of this collection in the IIIF-expected format.
Methods included from BaseProperties
#base_properties, #save, #type
Methods included from Utilities::Helpers
#escape_yaml, #generate_build_location, #generate_id, #generate_image_location, #get_data_path, #save_to_disk
Constructor Details
#initialize(config) ⇒ Collection
Returns a new instance of Collection.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/wax_iiif/collection.rb', line 13 def initialize(config) raise WaxIiif::Error::MissingCollectionName if config.collection_label.to_s.empty? @config = config @manifests = [] @collections = [] @label = @config.collection_label self.id = "collection/#{@label}" end |
Instance Attribute Details
#collections ⇒ Object (readonly)
Returns the value of attribute collections.
11 12 13 |
# File 'lib/wax_iiif/collection.rb', line 11 def collections @collections end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
11 12 13 |
# File 'lib/wax_iiif/collection.rb', line 11 def label @label end |
#manifests ⇒ Object (readonly)
Returns the value of attribute manifests.
11 12 13 |
# File 'lib/wax_iiif/collection.rb', line 11 def manifests @manifests end |
Instance Method Details
#add_collection(collection) ⇒ Object
24 25 26 27 |
# File 'lib/wax_iiif/collection.rb', line 24 def add_collection(collection) raise WaxIiif::Error::NotACollection unless collection.respond_to?(:type) && collection.type == Collection::TYPE @collections.push(collection) end |
#add_manifest(manifest) ⇒ Object
29 30 31 32 |
# File 'lib/wax_iiif/collection.rb', line 29 def add_manifest(manifest) raise WaxIiif::Error::NotAManifest unless manifest.respond_to?(:type) && manifest.type == Manifest::TYPE @manifests.push(manifest) end |
#to_json(*_args) ⇒ String
The JSON representation of this collection in the IIIF-expected format
39 40 41 42 43 44 |
# File 'lib/wax_iiif/collection.rb', line 39 def to_json(*_args) obj = base_properties obj['collections'] = collect_object(collections) unless collections.empty? obj['manifests'] = collect_object(manifests) unless manifests.empty? JSON.pretty_generate obj end |