require 'date' module Identification module Parser # Represents a document parser. # This class carries base methods that are required to process all documents. # # @private # @abstract Subclass and implement a {#parse} method for the specific document type. class Parser def self.yymmdd_to_ruby_date(input_date) # Only putting the last 2 digits of a date has the flaw of not knowing which century. # So I use the current year as a cut off. # Sorry to those over 100! :-( current_year_yy = (Date.today.strftime('%Y'))[2..4] input_year_yy = input_date[0..1] input_month = input_date[2..3] input_day = input_date[4..5] begin return Date.parse(input_day + '-' + input_month + '-' + '19' + input_year_yy) if input_year_yy >= current_year_yy rescue return false end begin return Date.parse(input_day + '-' + input_month + '-' + '20' + input_year_yy) rescue return false end end private_class_method :yymmdd_to_ruby_date end end end