extenso_pt 0.5.5 → 0.5.6
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/extenso_pt.rb +21 -15
- data/lib/extenso_pt/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5a2e148fdb3d9e6da43d502b722c57d3f17c2e21d2510c84647112f2bee214e0
|
|
4
|
+
data.tar.gz: ebeac8d8b3c34c8b8c84b2b9e1749f5f136351d7022cfdaea3517c54a5116afc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6e92c0d76988a0b986bbc56f7c2ee5ee5eb1d751b1f6da1c361e076442aed2307602b204a3dee701fe885e7bd905e206d08a47c48ba8b193f824955608bfe86b
|
|
7
|
+
data.tar.gz: 83a4a1f20b1349e4aba706a02ac7c0f6a301320272acc0d20ae5704d2adb626c858e991bbb693ec0012c13d7f316caa93a93da917027293511e7fcc3774d17e4
|
data/Gemfile.lock
CHANGED
data/lib/extenso_pt.rb
CHANGED
|
@@ -128,6 +128,7 @@ module ExtensoPt
|
|
|
128
128
|
|
|
129
129
|
# Parametrizar controle singular/plural & proposicoes
|
|
130
130
|
#
|
|
131
|
+
# @return [void]
|
|
131
132
|
def self.pcontrolo
|
|
132
133
|
# soma grupos 1,2 (primeiros 6 digitos)
|
|
133
134
|
@s6 = @ai[0].to_i + @ai[1].to_i * 2
|
|
@@ -159,6 +160,7 @@ module ExtensoPt
|
|
|
159
160
|
# Parametrizar parte inteira/fracionaria do valor monetario
|
|
160
161
|
#
|
|
161
162
|
# @param [String] dig string de digitos rdo valor monetario
|
|
163
|
+
# @return [void]
|
|
162
164
|
def self.pintfra(dig)
|
|
163
165
|
# parte inteira do valor monetario => array grupos 3 digitos
|
|
164
166
|
# ex: 123022.12 => [22, 123]
|
|
@@ -174,16 +176,17 @@ module ExtensoPt
|
|
|
174
176
|
#
|
|
175
177
|
# @param [Object] objeto objeto a converter
|
|
176
178
|
# (String, Float, Integer, Array, Range, Hash)
|
|
177
|
-
# @return [String
|
|
178
|
-
#
|
|
179
|
-
#
|
|
180
|
-
|
|
179
|
+
# @return [String, Array<extensos>, Hash<extensos>] string extenso
|
|
180
|
+
# se objecto for (String, Float, Integer),
|
|
181
|
+
# array se objecto for (Array, Range),
|
|
182
|
+
# hash se objecto for (Hash)
|
|
183
|
+
def self.eobjeto(obj)
|
|
181
184
|
if obj.is_a?(Hash)
|
|
182
185
|
# converte os valores do Hash nos seus extensos - devolve um Hash
|
|
183
|
-
obj.map { |k, v| [k,
|
|
186
|
+
obj.map { |k, v| [k, eobjeto(v)] }.to_h
|
|
184
187
|
elsif obj.respond_to?(:to_a)
|
|
185
188
|
# converte o objecto num Array com os extensos dos valores
|
|
186
|
-
obj.to_a.map { |v|
|
|
189
|
+
obj.to_a.map { |v| eobjeto(v) }
|
|
187
190
|
else
|
|
188
191
|
# converte objeto numa string de digitos
|
|
189
192
|
# usa bigdecimal/util para evitar aritmetica binaria
|
|
@@ -210,7 +213,8 @@ module ExtensoPt
|
|
|
210
213
|
# inferido do plural menos "S"
|
|
211
214
|
# @option moeda [String] :mplural moeda no plural
|
|
212
215
|
# @option moeda [String] :fplural fracao no plural
|
|
213
|
-
|
|
216
|
+
# @return [void]
|
|
217
|
+
def self.psingular(moeda)
|
|
214
218
|
@ms = moeda[:msingular] ||
|
|
215
219
|
(moeda[:mplural].to_s[-1] == 'S' ? moeda[:mplural][0..-2] : 'EURO')
|
|
216
220
|
@cs = moeda[:fsingular] ||
|
|
@@ -228,7 +232,8 @@ module ExtensoPt
|
|
|
228
232
|
# inferido do singular mais "S"
|
|
229
233
|
# @option moeda [String] :fplural fracao no plural -
|
|
230
234
|
# inferido do singular mais "S"
|
|
231
|
-
|
|
235
|
+
# @return [void]
|
|
236
|
+
def self.pplural(moeda)
|
|
232
237
|
# somente [:pt, :br]
|
|
233
238
|
@lc = LC.include?(moeda[:lc]) ? moeda[:lc] : :pt
|
|
234
239
|
|
|
@@ -245,9 +250,10 @@ module ExtensoPt
|
|
|
245
250
|
# @option moeda [String] :fsingular fracao no singular
|
|
246
251
|
# @option moeda [String] :mplural moeda no plural
|
|
247
252
|
# @option moeda [String] :fplural fracao no plural
|
|
248
|
-
# @return [String
|
|
249
|
-
#
|
|
250
|
-
#
|
|
253
|
+
# @return [String, Array<extensos>, Hash<extensos>] string extenso
|
|
254
|
+
# se objecto for (String, Float, Integer),
|
|
255
|
+
# array se objecto for (Array, Range),
|
|
256
|
+
# hash se objecto for (Hash)
|
|
251
257
|
def extenso(moeda = { lc: :pt, msingular: 'EURO', fsingular: 'CÊNTIMO' })
|
|
252
258
|
# parametrizacao por defeito para :br
|
|
253
259
|
if moeda[:lc] == :br && !moeda[:msingular] && !moeda[:mplural]
|
|
@@ -255,11 +261,11 @@ module ExtensoPt
|
|
|
255
261
|
end
|
|
256
262
|
|
|
257
263
|
# parametrizar moeda
|
|
258
|
-
ExtensoPt.
|
|
259
|
-
ExtensoPt.
|
|
264
|
+
ExtensoPt.psingular(moeda)
|
|
265
|
+
ExtensoPt.pplural(moeda)
|
|
260
266
|
|
|
261
|
-
#
|
|
262
|
-
ExtensoPt.
|
|
267
|
+
# extenso do objeto
|
|
268
|
+
ExtensoPt.eobjeto(self)
|
|
263
269
|
end
|
|
264
270
|
end
|
|
265
271
|
|
data/lib/extenso_pt/version.rb
CHANGED