Class: Ddr::Models::MetadataMapping
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Ddr::Models::MetadataMapping
- Defined in:
- lib/ddr/models/metadata/metadata_mapping.rb
Instance Attribute Summary collapse
-
#label ⇒ Object
Returns the value of attribute label.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(mapping = Hash.new, label = nil) ⇒ MetadataMapping
constructor
A new instance of MetadataMapping.
- #merge(other) ⇒ Object
- #terms ⇒ Object
- #unqualified_names ⇒ Object
Constructor Details
#initialize(mapping = Hash.new, label = nil) ⇒ MetadataMapping
Returns a new instance of MetadataMapping.
27 28 29 30 |
# File 'lib/ddr/models/metadata/metadata_mapping.rb', line 27 def initialize(mapping=Hash.new, label=nil) super(mapping) @label = label end |
Instance Attribute Details
#label ⇒ Object
Returns the value of attribute label.
25 26 27 |
# File 'lib/ddr/models/metadata/metadata_mapping.rb', line 25 def label @label end |
Class Method Details
.build(vocab, label = nil) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/ddr/models/metadata/metadata_mapping.rb', line 5 def build(vocab, label=nil) mapping = vocab.terms.each_with_object({}) do |term, memo| memo[term.qualified_name] = term end new(mapping, label) end |
.dc11 ⇒ Object
12 13 14 |
# File 'lib/ddr/models/metadata/metadata_mapping.rb', line 12 def dc11 @dc11 ||= build(MetadataVocabulary.dc11, "DC Elements").freeze end |
.dcterms ⇒ Object
16 17 18 |
# File 'lib/ddr/models/metadata/metadata_mapping.rb', line 16 def dcterms @dcterms ||= build(MetadataVocabulary.dcterms, "DC Terms").freeze end |
.duketerms ⇒ Object
20 21 22 |
# File 'lib/ddr/models/metadata/metadata_mapping.rb', line 20 def duketerms @duketerms ||= build(MetadataVocabulary.duketerms, "Duke Terms").freeze end |
Instance Method Details
#merge(other) ⇒ Object
40 41 42 |
# File 'lib/ddr/models/metadata/metadata_mapping.rb', line 40 def merge(other) MetadataMapping.new(__getobj__.merge(other)) end |
#terms ⇒ Object
32 33 34 |
# File 'lib/ddr/models/metadata/metadata_mapping.rb', line 32 def terms values end |
#unqualified_names ⇒ Object
36 37 38 |
# File 'lib/ddr/models/metadata/metadata_mapping.rb', line 36 def unqualified_names terms.map(&:unqualified_name) end |