Class: Mods::OriginInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/mods/origin_info.rb

Constant Summary collapse

DATE_ELEMENTS =
['dateIssued', 'dateCreated', 'dateCaptured', 'dateValid', 'dateModified', 'copyrightDate', 'dateOther']

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ OriginInfo

Returns a new instance of OriginInfo.


7
8
9
# File 'lib/mods/origin_info.rb', line 7

def initialize(xml)
  @xml = xml
end

Instance Attribute Details

#xmlObject (readonly)

Returns the value of attribute xml


5
6
7
# File 'lib/mods/origin_info.rb', line 5

def xml
  @xml
end

Instance Method Details

#datesObject


11
12
13
# File 'lib/mods/origin_info.rb', line 11

def dates
  DATE_ELEMENTS.flat_map { |element| xml.public_send(element) }
end

#key_datesObject


15
16
17
18
19
# File 'lib/mods/origin_info.rb', line 15

def key_dates
  d = dates.select { |x| x.keyDate == 'yes' }

  d += dates.select { |x| x.point == 'end' && d.any? { |date| date.name == x.name && date.point == 'start' } }
end