store_as_int 0.0.18 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/store_as_int/base.rb +7 -5
- 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: 02ea39aea7ea5f1df28231ca3edfe10611cc901cf29419d69a4d4cc367b6d0a1
|
4
|
+
data.tar.gz: cb7b188beb213d0f869a7b8f8a3259092ed4298175bb0765460e932dc26deea9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9744a5fbbb4f888f5b1a70ae9bf3769bd4dcb6e023270997527d7f07d544502a7e3fbf980700949648a452ac075c87b4b5e23f2f2765721c7e6621032fe19fa8
|
7
|
+
data.tar.gz: c12682e69f310b3bfc6b36ca4e18e2777e810b414bb5d28a02ed4cb3ea3b893737425039fac62bec6453c5c24700c23109c3d71d378b887f476879586df8809c
|
data/lib/store_as_int/base.rb
CHANGED
@@ -296,11 +296,12 @@ module StoreAsInt
|
|
296
296
|
def str_format
|
297
297
|
@str_format ||= self.class.str_format || ->(passed, w_sym, padding) do
|
298
298
|
return '' unless w_sym || passed.present? || (padding.to_i > 0)
|
299
|
-
|
299
|
+
prefix = "#{
|
300
300
|
passed.negative_sign
|
301
301
|
}#{
|
302
|
-
|
303
|
-
}
|
302
|
+
w_sym ? passed.sym : ''
|
303
|
+
}"
|
304
|
+
str = "#{
|
304
305
|
passed.decimals ?
|
305
306
|
sprintf("%0.0#{passed.decimals.to_i}f", passed.to_d.abs) :
|
306
307
|
passed.to_i.to_s
|
@@ -308,9 +309,10 @@ module StoreAsInt
|
|
308
309
|
|
309
310
|
str[-1] =
|
310
311
|
str[-1].
|
311
|
-
gsub(/(\d{3})(?=\d)/, w_sym ? '\\1,' : '\\1')
|
312
|
+
gsub(/(\d{3})(?=\d)/, w_sym ? '\\1,' : '\\1').
|
313
|
+
ljust(padding.to_i, ' ')
|
312
314
|
|
313
|
-
str.join('.').reverse
|
315
|
+
"#{prefix}#{str.join('.').reverse}"
|
314
316
|
end
|
315
317
|
end
|
316
318
|
end
|