Class: Hps::HpsCreditCard
- Inherits:
-
Object
- Object
- Hps::HpsCreditCard
- Defined in:
- lib/hps/entities/hps_credit_card.rb
Instance Attribute Summary collapse
-
#card_present ⇒ Object
Returns the value of attribute card_present.
-
#cvv ⇒ Object
Returns the value of attribute cvv.
-
#exp_month ⇒ Object
Returns the value of attribute exp_month.
-
#exp_year ⇒ Object
Returns the value of attribute exp_year.
-
#number ⇒ Object
Returns the value of attribute number.
-
#reader_present ⇒ Object
Returns the value of attribute reader_present.
Instance Method Summary collapse
- #card_type ⇒ Object
-
#initialize ⇒ HpsCreditCard
constructor
A new instance of HpsCreditCard.
Constructor Details
#initialize ⇒ HpsCreditCard
Returns a new instance of HpsCreditCard.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/hps/entities/hps_credit_card.rb', line 7 def initialize @regex_map = { :Amex => /^3[47][0-9]{13}$/, :MasterCard => /^5[1-5][0-9]{14}$/, :Visa => /^4[0-9]{12}(?:[0-9]{3})?$/, :DinersClub => /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/, :EnRoute => /^(2014|2149)/, :Discover => /^6(?:011|5[0-9]{2})[0-9]{12}$/, :Jcb => /^(?:2131|1800|35\\d{3})\\d{11}$/ } end |
Instance Attribute Details
#card_present ⇒ Object
Returns the value of attribute card_present.
4 5 6 |
# File 'lib/hps/entities/hps_credit_card.rb', line 4 def card_present @card_present end |
#cvv ⇒ Object
Returns the value of attribute cvv.
4 5 6 |
# File 'lib/hps/entities/hps_credit_card.rb', line 4 def cvv @cvv end |
#exp_month ⇒ Object
Returns the value of attribute exp_month.
4 5 6 |
# File 'lib/hps/entities/hps_credit_card.rb', line 4 def exp_month @exp_month end |
#exp_year ⇒ Object
Returns the value of attribute exp_year.
4 5 6 |
# File 'lib/hps/entities/hps_credit_card.rb', line 4 def exp_year @exp_year end |
#number ⇒ Object
Returns the value of attribute number.
4 5 6 |
# File 'lib/hps/entities/hps_credit_card.rb', line 4 def number @number end |
#reader_present ⇒ Object
Returns the value of attribute reader_present.
4 5 6 |
# File 'lib/hps/entities/hps_credit_card.rb', line 4 def reader_present @reader_present end |
Instance Method Details
#card_type ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/hps/entities/hps_credit_card.rb', line 21 def card_type @regex_map.each { |key, value| unless value.match(number.to_s).nil? return key end } "Unknown" end |