mxn_banks 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mxn_banks.rb +3 -1
- data/lib/mxn_banks/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6664301549097899dddac52742d96c6673b6649f
|
4
|
+
data.tar.gz: 6bc4a27ca4b272271ecb460036c0918ab2db029f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3d1e3bfda70db2f7b03703dcbc285e6ab00246ad06ed436b624b754613d234d867d0bdc78c4fea79177b9a843c6029b00953ca20a99ed8449bcc11e95091eeb
|
7
|
+
data.tar.gz: 292e8f1d4707e4fecb11e22fa623ab68215b868315ff978c218a44383125b2e86d7b87e759c672884fd6e16e38cd532c82cb3ad627328088d2b728671bf18d7b
|
data/lib/mxn_banks.rb
CHANGED
@@ -4,6 +4,7 @@ module MxnBanks
|
|
4
4
|
autoload :Bank, 'mxn_banks/bank'
|
5
5
|
def self.from_iban(num)
|
6
6
|
a = to_hash.select { |b| b[:number] == num.slice(0, 3) }
|
7
|
+
fail ArgumentError,'Invalid bank code' if a.empty?
|
7
8
|
Bank.new(a.first)
|
8
9
|
end
|
9
10
|
|
@@ -13,6 +14,7 @@ module MxnBanks
|
|
13
14
|
end
|
14
15
|
|
15
16
|
def self.valid?(clabe)
|
17
|
+
return false if clabe.length < 18
|
16
18
|
sliced_clabe = clabe.slice(0,17).split('')
|
17
19
|
w_factor = weight(sliced_clabe)
|
18
20
|
module_ten = sliced_clabe.map.with_index { |n, i| (n.to_i * w_factor[i]).modulo(10) }
|
@@ -28,6 +30,6 @@ module MxnBanks
|
|
28
30
|
|
29
31
|
def self.current_control_digit(arr)
|
30
32
|
module_sum = arr.reduce { |sum, n| sum + n }
|
31
|
-
10 - module_sum.modulo(10)
|
33
|
+
(10 - module_sum.modulo(10)).modulo(10)
|
32
34
|
end
|
33
35
|
end
|
data/lib/mxn_banks/version.rb
CHANGED