module Stockboy::Translations::Date::PatternMatching
Constants
- MATCH_YYYY
Match date strings with 4-digit year
- SLASH
Private Class Methods
included(base)
click to toggle source
# File lib/stockboy/translations/date.rb, line 59 def self.included(base) base.extend ClassMethods end
Private Instance Methods
date_format(value)
click to toggle source
# File lib/stockboy/translations/date.rb, line 73 def date_format(value) self.class.patterns[yy_index(value) + sep_index(value)].freeze end
parse_date(value)
click to toggle source
@return [Date]
# File lib/stockboy/translations/date.rb, line 69 def parse_date(value) ::Date.strptime(value, date_format(value)) end
sep_index(value)
click to toggle source
# File lib/stockboy/translations/date.rb, line 81 def sep_index(value) value.include?(SLASH) ? 1 : 0 end
yy_index(value)
click to toggle source
# File lib/stockboy/translations/date.rb, line 77 def yy_index(value) value =~ MATCH_YYYY ? 0 : 2 end