Class: Cielo::Card::Validity
- Inherits:
-
Object
- Object
- Cielo::Card::Validity
- Defined in:
- lib/cielo/card/validity.rb
Defined Under Namespace
Classes: InvalidDate
Instance Method Summary collapse
-
#initialize(year, month) ⇒ Validity
constructor
A new instance of Validity.
- #to_s ⇒ Object
Constructor Details
#initialize(year, month) ⇒ Validity
Returns a new instance of Validity.
6 7 8 9 10 11 12 13 14 |
# File 'lib/cielo/card/validity.rb', line 6 def initialize(year, month) @year = year.to_i @month = month.to_i now = Time.now if @year < now.year || (@year == now.year && @month < now.month) raise InvalidDate, "#{@month}/#{@year} is not valid" end end |
Instance Method Details
#to_s ⇒ Object
16 17 18 |
# File 'lib/cielo/card/validity.rb', line 16 def to_s [@year, "%02d" % @month].join end |