Class: Krikri::Enrichments::TimespanLabel

Inherits:
Object
  • Object
show all
Includes:
Audumbla::FieldEnrichment
Defined in:
lib/krikri/enrichments/timespan_label.rb

Overview

Builds and sets a ‘prefLabel` based on existing begin/end dates within an `edm:TimeSpan`.

Examples:

date = DPLA::MAP::TimeSpan.new.tap do |t| 
  t.begin = Date.today
  t.end = (Date.today + 1)
end

TimespanLabel.new.enrich_value(date).prefLabel
# => ["2016-07-08/2016-07-09"]

Instance Method Summary collapse

Instance Method Details

#enrich_value(value) ⇒ DPLA::MAP::TimeSpan, Object

Add a prefLabel for ‘DPLA::MAP::TimeSpan` objects with begin/end dates

Parameters:

  • value (DPLA::MAP::TimeSpan, String, Object)

Returns:

  • (DPLA::MAP::TimeSpan, Object)

    a new ‘TimeSpan` object containing the generated prefLabel



25
26
27
28
29
# File 'lib/krikri/enrichments/timespan_label.rb', line 25

def enrich_value(value)
  set_label(value) if value.is_a?(DPLA::MAP::TimeSpan) && 
                      value.prefLabel.empty?
  value
end