formatos-febraban 0.3.22 → 0.3.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/base/position.rb +14 -11
- data/lib/formatos/febraban/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: 66e4c6f43c1ae22579b3909dceb3fd2f405133d3
|
4
|
+
data.tar.gz: 0cfdd5c67ffec53bc95b88deb6f77e5ee09e3912
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e65dcc0c1fae7e54f102bd1cbaeea7a9540923bcbb7d4fd8e19e4340a5454130019c6e1a5ff26ed36878c9ef43a13c825a1072542535c82d9aa64abec944a93a
|
7
|
+
data.tar.gz: 70263bd1a5abd7eec06ad5cd830ac964c987134ba703208b5a978f702bcb47ddc765c917cbff674aec089eb10ae63a44ef54a2a69030c265a6cf77c34d935cf8
|
data/Gemfile
CHANGED
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 =
|
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
|
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
|
61
|
+
raise 'Valor imutável'
|
60
62
|
end
|
61
63
|
end
|
62
64
|
|
63
|
-
def
|
64
|
-
|
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,
|
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
|