formatos-febraban 0.3.22 → 0.3.23

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad57e556b37d0dc24df2851ce2e63db02152c6a0
4
- data.tar.gz: 010c03dd47f202b83395eea01c8efa24298fc12c
3
+ metadata.gz: 66e4c6f43c1ae22579b3909dceb3fd2f405133d3
4
+ data.tar.gz: 0cfdd5c67ffec53bc95b88deb6f77e5ee09e3912
5
5
  SHA512:
6
- metadata.gz: 11ae17132de60fde3d1a64c5ade71c81d18b4388b1928a033b1fcd409be8dd3cc44f7d635318b7f02232953d950906f91cee821ae0cb3946cdf4b6f35450ff4c
7
- data.tar.gz: 21749a56c31d580be86c97aee13d2fc28d29bfa80d47eb832662911c502b9106984fcd15d972b14b13b31069bba9b218c6c316a5ce3b3f28a3dfebd3d5d1e10c
6
+ metadata.gz: e65dcc0c1fae7e54f102bd1cbaeea7a9540923bcbb7d4fd8e19e4340a5454130019c6e1a5ff26ed36878c9ef43a13c825a1072542535c82d9aa64abec944a93a
7
+ data.tar.gz: 70263bd1a5abd7eec06ad5cd830ac964c987134ba703208b5a978f702bcb47ddc765c917cbff674aec089eb10ae63a44ef54a2a69030c265a6cf77c34d935cf8
data/Gemfile CHANGED
@@ -4,4 +4,4 @@ ruby '2.2.2'
4
4
 
5
5
  # Specify your gem's dependencies in formatos-febraban.gemspec
6
6
  gemspec
7
- gem 'enumerate_it'
7
+ gem 'i18n'
data/base/position.rb CHANGED
@@ -1,7 +1,9 @@
1
1
 
2
2
  class Position
3
+ require 'i18n'
4
+
3
5
  def initialize(position, length, numbers_only,
4
- content = "", immutable = false, obligatory = false)
6
+ content = '', immutable = false, obligatory = false)
5
7
 
6
8
  @position = position
7
9
  @length = length
@@ -47,7 +49,7 @@ class Position
47
49
  self.to_s.strip()
48
50
  end
49
51
 
50
- def set_content content
52
+ def set_content(content)
51
53
  if not @immutable
52
54
  if self.is_numbers_only? and !self.is_number(content)
53
55
  raise "Apenas valores numéricos
@@ -56,22 +58,27 @@ class Position
56
58
 
57
59
  @content = self.adjust_content(content)
58
60
  else
59
- raise "Valor imutável"
61
+ raise 'Valor imutável'
60
62
  end
61
63
  end
62
64
 
63
- def adjust_content string
64
- string = string.to_s
65
+ def is_number(value)
66
+ true if Float(value) rescue false
67
+ end
68
+
69
+ protected
70
+ def adjust_content(string)
71
+ string = I18n.transliterate(string.to_s)
65
72
 
66
73
  if string.length > self.length
67
74
  string = self.reduce_string string
68
75
 
69
76
  elsif string.length < self.length
70
77
  if self.is_numbers_only?
71
- string = string.rjust(self.length, "0")
78
+ string = string.rjust(self.length, '0')
72
79
 
73
80
  else
74
- string = string.ljust(self.length, " ")
81
+ string = string.ljust(self.length, ' ')
75
82
  end
76
83
  end
77
84
 
@@ -81,8 +88,4 @@ class Position
81
88
  def reduce_string(string)
82
89
  string[0 .. self.length - 1]
83
90
  end
84
-
85
- def is_number value
86
- true if Float(value) rescue false
87
- end
88
91
  end
@@ -1,5 +1,5 @@
1
1
  module Formatos
2
2
  module Febraban
3
- VERSION = '0.3.22'
3
+ VERSION = '0.3.23'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formatos-febraban
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.22
4
+ version: 0.3.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - José Ricardo Almeida