class PeanutLabs::Parser::DateOfBirth
Public Class Methods
iframe(value)
click to toggle source
This method formats DateTime, Date, Time to time format required for Iframe (MM-DD-YYYY) It also checks if string is already formatted correctly Can return NIL
# File lib/peanut_labs/parser/date_of_birth.rb, line 11 def iframe(value) retrieve_date(value, /^\d{2}-\d{2}-\d{4}$/, '%m-%d-%Y') end
profile(value)
click to toggle source
This method formats DateTime, Date, Time to time format required for Profile class (YYYY-MM-DD) It also checks if string is already formatted correctly Can return NIL
# File lib/peanut_labs/parser/date_of_birth.rb, line 19 def profile(value) retrieve_date(value, /^\d{4}-\d{2}-\d{2}$/, '%Y-%m-%d') end
Private Class Methods
retrieve_date(value, correct_regexp, format_as)
click to toggle source
# File lib/peanut_labs/parser/date_of_birth.rb, line 25 def retrieve_date(value, correct_regexp, format_as) return value if value.nil? return value.strftime(format_as) if value.is_a?(Date) || value.is_a?(DateTime) || value.is_a?(Time) return value if value.match?(correct_regexp) nil end