Class: CreditCardDetector::Brand
- Inherits:
-
Object
- Object
- CreditCardDetector::Brand
- Defined in:
- lib/credit_card_detector/brand.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(id, data) ⇒ Brand
constructor
A new instance of Brand.
- #luhn? ⇒ Boolean
- #matches?(number) ⇒ Boolean
- #name ⇒ Object
- #rules ⇒ Object
Constructor Details
#initialize(id, data) ⇒ Brand
Returns a new instance of Brand.
7 8 9 10 11 |
# 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 |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/credit_card_detector/brand.rb', line 5 def id @id end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/credit_card_detector/brand.rb', line 5 def @options end |
Instance Method Details
#luhn? ⇒ Boolean
21 22 23 |
# File 'lib/credit_card_detector/brand.rb', line 21 def luhn? !.fetch(:skip_luhn, false) end |
#matches?(number) ⇒ Boolean
17 18 19 |
# File 'lib/credit_card_detector/brand.rb', line 17 def matches?(number) rules.any? { |rule| rule.matches? number } end |
#name ⇒ Object
13 14 15 |
# File 'lib/credit_card_detector/brand.rb', line 13 def name .fetch(:brand_name) end |