Class: Mods::Date::MMDDYYYYFormat

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

Overview

Full text extractor for MM/DD/YYYY-formatted dates

Constant Summary collapse

REGEX =
/(?<month>\d{1,2})\/(?<day>\d{1,2})\/(?<year>\d{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



100
101
102
103
# File 'lib/mods/date.rb', line 100

def self.cleanup(text)
  matches = text.match(self::REGEX)
  "#{matches[:year].rjust(2, "0")}-#{matches[:month].rjust(2, "0")}-#{matches[:day].rjust(2, "0")}"
end