luhn_validate 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/luhn_validate.rb +4 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c3e71654c289bf40da1ad883e139357757cb482335135e45fe9c034bd8b07a2b
4
- data.tar.gz: e3c5b37cc9c16355492b482a9b4b1b3e45f048db51d8935a854ea8cc23fda734
3
+ metadata.gz: 5319bba089008f18c127dfbd48a39e100e82f52e06bcf0610f0ca0357705aea9
4
+ data.tar.gz: 77211d698a949c0db1456054b0e7fa1bac1f96cee331a0e40dece40491248aca
5
5
  SHA512:
6
- metadata.gz: 1932ed330cd915211831e07d673d782dd87b5809c71578515952b1dd7b202ee34794c8397db56b02ca2ed8fefdab7405d55ca2f539e0a392826adea3a3044aa3
7
- data.tar.gz: 1f109d5572354b58f16b5ff510ee1281351cc48f870f0edfe0451d2d2d672110facb69ba0e63fc09aa7cf3955e6f6c3d415532ae309939426d2c2b67669f5e82
6
+ metadata.gz: db8fa3654e14858c0d017483202131b9c7153323a3d476457731342b8db6d7f9ed447d2f19b3081994c081c6599bda6a3f72e352fb3871d87c11d8c78bfdedb5
7
+ data.tar.gz: 95e6a7e788abae9ce1c8345604516a70d276f2c44d29cee0afb7e17997ecf66c0294185b89ecad8a4193a8c3fa3711288a1a814d583694082ea038ac38722c0a
data/lib/luhn_validate.rb CHANGED
@@ -4,6 +4,7 @@
4
4
  class Luhn
5
5
  class CardNotPresentError < StandardError; end
6
6
  class PanLengthError < StandardError; end
7
+ class PanTypeError < StandardError; end
7
8
 
8
9
  attr_reader :pan_array, :card_size, :valid
9
10
 
@@ -15,9 +16,10 @@ class Luhn
15
16
 
16
17
  def self.validate(pan)
17
18
  raise CardNotPresentError, 'Card not present' unless pan
18
- raise PanLengthError, 'Wrong pan length' unless (14..19).include? pan.split('').size
19
+ raise PanTypeError, 'Wrong pan type, pan must be either String or Integer' unless pan.is_a?(String) || pan.is_a?(Integer)
20
+ raise PanLengthError, 'Wrong pan length' unless (14..19).include? pan.to_s.split('').size
19
21
 
20
- new(pan)
22
+ new(pan.to_s)
21
23
  end
22
24
 
23
25
  private
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: luhn_validate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - FuryCow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-11 00:00:00.000000000 Z
11
+ date: 2023-09-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Validate Card PAN by Luhn algorithm
14
14
  email: dreamweaver0408@gmail.com