Class: Mods::Date::EmbeddedYearFormat

Inherits:
ExtractorDateFormat show all
Defined in:
lib/mods/date.rb

Overview

Full-text extractor that tries hard to pick any year present in the data

Constant Summary collapse

REGEX =
/(?<prefix>-)?(?<year>\d{3,4})/

Instance Attribute Summary

Attributes inherited from Mods::Date

#date, #xml

Class Method Summary collapse

Methods inherited from ExtractorDateFormat

supports?

Methods inherited from Mods::Date

#approximate?, #as_range, #encoding, #encoding?, #end?, from_element, #inferred?, #initialize, parse_date, #point, #qualifier, #questionable?, #single?, #start?, #text, #to_a, #type

Constructor Details

This class inherits a constructor from Mods::Date

Class Method Details

.cleanup(text) ⇒ Object



188
189
190
191
# File 'lib/mods/date.rb', line 188

def self.cleanup(text)
  matches = text.match(REGEX)
  "#{matches[:prefix]}#{matches[:year].rjust(4, "0")}"
end