Class: CreditCardValidator::CreditCardBrandName
- Inherits:
-
Object
- Object
- CreditCardValidator::CreditCardBrandName
- Defined in:
- lib/credit_card_validator/credit_card_brand_name.rb
Constant Summary collapse
- CARD_BRANDS =
{ master_card: /^5[1-5][0-9]{14}$|^2(?:2(?:2[1-9]|[3-9][0-9])|[3-6][0-9][0-9]|7(?:[01][0-9]|20))[0-9]{12}$/, american_express: /^3[47][0-9]{13}$/, visa: /^4[0-9]{12}(?:[0-9]{3})?$/, discover: /^65[4-9][0-9]{13}|64[4-9][0-9]{13}|6011[0-9]{12}|(622(?:12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|9[01][0-9]|92[0-5])[0-9]{10})$/, diners_club: /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/, jcb: /^(?:2131|1800|35[0-9]{3})[0-9]{11}$/ }
Class Method Summary collapse
Class Method Details
.verify_card_brand(number) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/credit_card_validator/credit_card_brand_name.rb', line 12 def self.verify_card_brand(number) return false unless ValidateCard.card_number_validate(number) CARD_BRANDS.each do |key, value| pattern = Regexp.new(value) if pattern.match?(number.to_s) return key #.to_s.tr("_"," ").capitalize end end end |