Class: Dolla::CardNumberPrefix

Inherits:
Object
  • Object
show all
Defined in:
lib/dolla/card_number_prefix.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#bankObject

Returns the value of attribute bank.



3
4
5
# File 'lib/dolla/card_number_prefix.rb', line 3

def bank
  @bank
end

#prefixObject

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

Returns:

  • (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_amexObject



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