Class: Dolla::CardNumberPrefix
- Inherits:
-
Object
- Object
- Dolla::CardNumberPrefix
- Defined in:
- lib/dolla/card_number_prefix.rb
Instance Attribute Summary collapse
-
#bank ⇒ Object
Returns the value of attribute bank.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ CardNumberPrefix
constructor
A new instance of CardNumberPrefix.
Constructor Details
#initialize(args = {}) ⇒ CardNumberPrefix
Returns a new instance of CardNumberPrefix.
5 6 7 8 |
# File 'lib/dolla/card_number_prefix.rb', line 5 def initialize(args = {}) @prefix = args[:prefix] @bank = args[:bank] end |
Instance Attribute Details
#bank ⇒ Object
Returns the value of attribute bank.
3 4 5 |
# File 'lib/dolla/card_number_prefix.rb', line 3 def bank @bank end |
#prefix ⇒ Object
Returns the value of attribute prefix.
3 4 5 |
# File 'lib/dolla/card_number_prefix.rb', line 3 def prefix @prefix end |
Class Method Details
.card_number_is_amex?(number) ⇒ Boolean
18 19 20 |
# File 'lib/dolla/card_number_prefix.rb', line 18 def self.card_number_is_amex? number number.to_s.match /^(34|37)/ end |
.is_amex ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/dolla/card_number_prefix.rb', line 10 def self.is_amex prefixes = ::Dolla::CardPrefix::Amex::PREFIXES prefixes.map do |prefix| new(prefix: prefix, bank: :amex) end end |