Class: IiifPrint::Metadata
- Inherits:
-
Object
- Object
- IiifPrint::Metadata
- Defined in:
- lib/iiif_print/metadata.rb
Overview
rubocop:disable Metrics/ClassLength
Instance Attribute Summary collapse
-
#current_ability ⇒ Object
readonly
Returns the value of attribute current_ability.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
-
#work ⇒ Object
readonly
Returns the value of attribute work.
Class Method Summary collapse
Instance Method Summary collapse
- #build_metadata ⇒ Object
-
#initialize(work:, version:, fields:, current_ability:, base_url:) ⇒ Metadata
constructor
A new instance of Metadata.
Constructor Details
#initialize(work:, version:, fields:, current_ability:, base_url:) ⇒ Metadata
Returns a new instance of Metadata.
12 13 14 15 16 17 18 |
# File 'lib/iiif_print/metadata.rb', line 12 def initialize(work:, version:, fields:, current_ability:, base_url:) @work = work @version = version.to_i @fields = fields @current_ability = current_ability @base_url = base_url end |
Instance Attribute Details
#current_ability ⇒ Object (readonly)
Returns the value of attribute current_ability.
20 21 22 |
# File 'lib/iiif_print/metadata.rb', line 20 def current_ability @current_ability end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
20 21 22 |
# File 'lib/iiif_print/metadata.rb', line 20 def fields @fields end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
20 21 22 |
# File 'lib/iiif_print/metadata.rb', line 20 def version @version end |
#work ⇒ Object (readonly)
Returns the value of attribute work.
20 21 22 |
# File 'lib/iiif_print/metadata.rb', line 20 def work @work end |
Class Method Details
.build_metadata_for(work:, version:, fields:, current_ability:, base_url:) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/iiif_print/metadata.rb', line 4 def self.(work:, version:, fields:, current_ability:, base_url:) new(work: work, version: version, fields: fields, current_ability: current_ability, base_url: base_url). end |
Instance Method Details
#build_metadata ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/iiif_print/metadata.rb', line 22 def fields.map do |field| values = values_for(field_name: field) if field.name == :collection && member_of_collection? && viewable_collections.present? { 'label' => (field, :label), 'value' => (field, :collection) } elsif values.present? && !empty_string?(values) { 'label' => (field, :label), 'value' => (field, :value) } end end.compact end |