core_extend 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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/core_extend/float_module.rb +10 -4
- data/lib/core_extend/integer.rb +4 -0
- data/lib/core_extend/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb28ccf2b597a267a05f52d59d3e1f955b1b9897
|
4
|
+
data.tar.gz: 47288a5a6295e46269ebc4958e1734676f0d80af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6d485f9f03937d27fc81b2fb19325d1b324e85079f2dbc1cb143a100d25d499144623c29f7d96e2e62d98057354b99ebd45e639d924ac1c296c7655267ca9f6
|
7
|
+
data.tar.gz: c6e5d2642f77041cf2fd85936ac5f9c2ab8bf583bfcbdb33bcbdb6ed65cb9dacdf8bda95c68a6e564688042e028bef64dbc379e49eb9771a76b0889dd7ff0aed
|
data/Gemfile.lock
CHANGED
@@ -3,7 +3,8 @@ module CoreExtend
|
|
3
3
|
|
4
4
|
#保留小数点位数
|
5
5
|
def decimal_point(point=2)
|
6
|
-
sprintf("%0.#{point}f", self).to_f
|
6
|
+
return sprintf("%0.#{point}f", self).to_f if point>0
|
7
|
+
self.to_i
|
7
8
|
end
|
8
9
|
|
9
10
|
#显示成钱数
|
@@ -16,21 +17,26 @@ module CoreExtend
|
|
16
17
|
int_str = str.split('.')[0]
|
17
18
|
point_str = str.split('.')[1]
|
18
19
|
|
20
|
+
return_value = ->() {
|
21
|
+
return "#{int_str}.#{point_str}" if point>0
|
22
|
+
int_str
|
23
|
+
}
|
24
|
+
|
19
25
|
if type=='text'
|
20
|
-
return
|
26
|
+
return return_value.call if int_str.to_i<10000
|
21
27
|
|
22
28
|
return "#{(int_str.to_i/10000.0).decimal_point(point)}万" if int_str.to_i<100000000
|
23
29
|
|
24
30
|
return "#{(int_str.to_i/100000000.0).decimal_point(point)}亿"
|
25
31
|
end
|
26
32
|
|
27
|
-
return
|
33
|
+
return return_value.call if int_str.length<3
|
28
34
|
index = -4
|
29
35
|
while index.abs < int_str.length+1
|
30
36
|
int_str.insert(index, ',')
|
31
37
|
index -=4
|
32
38
|
end
|
33
|
-
|
39
|
+
return_value.call
|
34
40
|
end
|
35
41
|
end
|
36
42
|
end
|
data/lib/core_extend/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: core_extend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- saxer
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- lib/core_extend/big_decimal.rb
|
61
61
|
- lib/core_extend/float.rb
|
62
62
|
- lib/core_extend/float_module.rb
|
63
|
+
- lib/core_extend/integer.rb
|
63
64
|
- lib/core_extend/version.rb
|
64
65
|
homepage: https://github.com/mumaoxi/core_extend
|
65
66
|
licenses:
|