Class: Creditcard::ExpiryDate

Inherits:
Object
  • Object
show all
Defined in:
app/models/creditcard.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(month, year) ⇒ ExpiryDate

Returns a new instance of ExpiryDate.



14
15
16
17
# File 'app/models/creditcard.rb', line 14

def initialize(month, year)
  @month = month
  @year = year
end

Instance Attribute Details

#monthObject (readonly)

Returns the value of attribute month.



13
14
15
# File 'app/models/creditcard.rb', line 13

def month
  @month
end

#yearObject (readonly)

Returns the value of attribute year.



13
14
15
# File 'app/models/creditcard.rb', line 13

def year
  @year
end

Instance Method Details

#expirationObject

:nodoc:



23
24
25
# File 'app/models/creditcard.rb', line 23

def expiration #:nodoc:
  Time.parse("#{month}/#{month_days}/#{year} 23:59:59") rescue Time.at(0)
end

#expired?Boolean

:nodoc:

Returns:

  • (Boolean)


19
20
21
# File 'app/models/creditcard.rb', line 19

def expired? #:nodoc:
  Time.now > expiration rescue true
end