Class: Mods::Date::RomanNumeralCenturyFormat
- Inherits:
-
RomanNumeralYearFormat
- Object
- Mods::Date
- ExtractorDateFormat
- RomanNumeralYearFormat
- Mods::Date::RomanNumeralCenturyFormat
- Defined in:
- lib/mods/date.rb
Overview
Full-text extractor for centuries encoded as Roman numerals; sometimes centuries are given as e.g. xvith, hence the funny negative look-ahead assertion
Constant Summary collapse
- REGEX =
/(?<![a-z])(?<century>[xvi]+)(?![a-su-z])/
Instance Attribute Summary
Attributes inherited from Mods::Date
Class Method Summary collapse
Methods inherited from RomanNumeralYearFormat
Methods inherited from ExtractorDateFormat
Methods inherited from Mods::Date
#approximate?, #as_range, #encoding, #encoding?, #end?, from_element, #inferred?, #initialize, #key?, parse_date, #point, #precision, #qualifier, #questionable?, #single?, #start?, #text, #to_a, #type
Constructor Details
This class inherits a constructor from Mods::Date
Class Method Details
.munge_to_yyyy(text) ⇒ Object
184 185 186 187 |
# File 'lib/mods/date.rb', line 184 def self.munge_to_yyyy(text) value = roman_to_int(text.upcase) (value - 1).to_s.rjust(2, "0") + 'XX' end |
.normalize_to_edtf(text) ⇒ Object
179 180 181 182 |
# File 'lib/mods/date.rb', line 179 def self.normalize_to_edtf(text) matches = text.match(REGEX) munge_to_yyyy(matches[:century]) end |