Module: UmbrellioUtils::Cards
- Extended by:
- Cards
- Included in:
- Cards
- Defined in:
- lib/umbrellio_utils/cards.rb
Defined Under Namespace
Classes: InvalidExpiryDateString
Instance Method Summary
collapse
Instance Method Details
#parse_expiry_date(string) ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/umbrellio_utils/cards.rb', line 20
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) ⇒ Object
10
11
12
13
14
15
16
17
18
|
# File 'lib/umbrellio_utils/cards.rb', line 10
def parse_expiry_date!(string, **)
result = parse_expiry_date(string, **)
unless result
raise InvalidExpiryDateString, "Failed to parse expiry date: #{string.inspect}"
end
result
end
|