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
Constant Summary collapse
- REGEX =
/(cent. )?(?<century>[xvi]+)/
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, 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
152 153 154 155 |
# File 'lib/mods/date.rb', line 152 def self.cleanup(text) matches = text.match(REGEX) munge_to_yyyy(matches[:century]) end |
.munge_to_yyyy(text) ⇒ Object
157 158 159 160 |
# File 'lib/mods/date.rb', line 157 def self.munge_to_yyyy(text) value = roman_to_int(text.upcase) (value - 1).to_s.rjust(2, "0") + 'XX' end |