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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b3b5ecbe15f286815a787c2df995fe9f1eb9b9cb
4
- data.tar.gz: 54e815dc1f00074413915898ad4b1a2710d45ef9
3
+ metadata.gz: 6664301549097899dddac52742d96c6673b6649f
4
+ data.tar.gz: 6bc4a27ca4b272271ecb460036c0918ab2db029f
5
5
  SHA512:
6
- metadata.gz: 3e075bef4ff6728bec903c5ef51178d269fccced255fba283bb0e46aee3dafcff37c3b4694435a6a92db1e3e89c013159836fde350db575789709c0fd5e74f73
7
- data.tar.gz: 77e8a98cb953b4b1cfcea2afde53225843b669c37101c0a83942684221bde8c7e885f5eb68842c994639b8b715fbcbb832c237d9d178f2bbbed15333d83f3846
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
@@ -1,3 +1,3 @@
1
1
  module MxnBanks
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.1.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mxn_banks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - aldosolorzano