Module: UmbrellioUtils::Cards
Constant Summary collapse
- InvalidExpiryDateString =
Class.new(StandardError)
Instance Method Summary collapse
Instance Method Details
#parse_expiry_date(string) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/umbrellio_utils/cards.rb', line 19 def parse_expiry_date(string) month, year = string.split("/", 2).map(&:to_i) return unless month && year year += 2000 if year < 100 time = suppress(ArgumentError) { Time.zone.local(year, month) } time + 1.month - 1.second if time end |
#parse_expiry_date!(string, **options) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/umbrellio_utils/cards.rb', line 9 def parse_expiry_date!(string, **) result = parse_expiry_date(string, **) unless result raise InvalidExpiryDateString, "Failed to parse expiry date: #{string.inspect}" end result end |