class CreditCardDetector::Brand

Attributes

id[R]
options[R]

Public Class Methods

new(id, data) click to toggle source
# File lib/credit_card_detector/brand.rb, line 7
def initialize(id, data)
  @id = id
  @raw_rules = data.fetch(:rules)
  @options = data.fetch(:options, {})
end

Public Instance Methods

luhn?() click to toggle source
# File lib/credit_card_detector/brand.rb, line 21
def luhn?
  !options.fetch(:skip_luhn, false)
end
matches?(number) click to toggle source
# File lib/credit_card_detector/brand.rb, line 17
def matches?(number)
  rules.any? { |rule| rule.matches? number }
end
name() click to toggle source
# File lib/credit_card_detector/brand.rb, line 13
def name
  options.fetch(:brand_name)
end
rules() click to toggle source
# File lib/credit_card_detector/brand.rb, line 25
def rules
  @rules ||= @raw_rules.map { |rule| Rule.new rule }
end