Class: CreditCardValidations::Card
- Inherits:
-
Object
- Object
- CreditCardValidations::Card
- Includes:
- ActiveModel::Model
- Defined in:
- lib/credit_card_validations/card.rb
Instance Attribute Summary collapse
-
#month ⇒ Object
Returns the value of attribute month.
-
#name ⇒ Object
Returns the value of attribute name.
-
#number ⇒ Object
Returns the value of attribute number.
-
#verification_value ⇒ Object
Returns the value of attribute verification_value.
-
#year ⇒ Object
Returns the value of attribute year.
Instance Method Summary collapse
- #brand ⇒ Object
- #brand_name ⇒ Object
- #detector ⇒ Object
- #display_number ⇒ Object
- #expiration ⇒ Object
- #expired? ⇒ Boolean
- #formatted_number ⇒ Object
- #last_digits ⇒ Object
Instance Attribute Details
#month ⇒ Object
Returns the value of attribute month.
26 27 28 |
# File 'lib/credit_card_validations/card.rb', line 26 def month @month end |
#name ⇒ Object
Returns the value of attribute name.
26 27 28 |
# File 'lib/credit_card_validations/card.rb', line 26 def name @name end |
#number ⇒ Object
Returns the value of attribute number.
26 27 28 |
# File 'lib/credit_card_validations/card.rb', line 26 def number @number end |
#verification_value ⇒ Object
Returns the value of attribute verification_value.
26 27 28 |
# File 'lib/credit_card_validations/card.rb', line 26 def verification_value @verification_value end |
#year ⇒ Object
Returns the value of attribute year.
26 27 28 |
# File 'lib/credit_card_validations/card.rb', line 26 def year @year end |
Instance Method Details
#brand ⇒ Object
32 |
# File 'lib/credit_card_validations/card.rb', line 32 def brand = detector.brand |
#brand_name ⇒ Object
33 |
# File 'lib/credit_card_validations/card.rb', line 33 def brand_name = detector.brand_name |
#detector ⇒ Object
48 49 50 |
# File 'lib/credit_card_validations/card.rb', line 48 def detector @detector ||= Detector.new(number) end |
#display_number ⇒ Object
35 |
# File 'lib/credit_card_validations/card.rb', line 35 def display_number = detector.masked |
#expiration ⇒ Object
38 39 40 41 |
# File 'lib/credit_card_validations/card.rb', line 38 def expiration return nil unless month && year Expiration.new(month, year) end |
#expired? ⇒ Boolean
43 44 45 46 |
# File 'lib/credit_card_validations/card.rb', line 43 def expired? exp = expiration exp.nil? || exp.expired? end |
#formatted_number ⇒ Object
36 |
# File 'lib/credit_card_validations/card.rb', line 36 def formatted_number = detector.formatted |
#last_digits ⇒ Object
34 |
# File 'lib/credit_card_validations/card.rb', line 34 def last_digits = detector.last4 |