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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8618ac69020c0bab44a6edd543a856ba0171c7ca
4
- data.tar.gz: a4955a463de873673ecb1b72aa394947170df69a
3
+ metadata.gz: fb28ccf2b597a267a05f52d59d3e1f955b1b9897
4
+ data.tar.gz: 47288a5a6295e46269ebc4958e1734676f0d80af
5
5
  SHA512:
6
- metadata.gz: a6e7e46a3a8cb5e38ef174c14802d13de6a48b2e1e23b4136048e99101986a62d4f7492bc595babc7d288ecd105ae75c77d0ffc94faeb531b7b929b40dcf850c
7
- data.tar.gz: 871df135903b64ee3cfbc19028359a7102b35b03335dff6e270e02390559ac9b6a7e3a705a5085e1275f3c9bb8a4a7358962d5529ffd0b2cd9523dcc7862d304
6
+ metadata.gz: f6d485f9f03937d27fc81b2fb19325d1b324e85079f2dbc1cb143a100d25d499144623c29f7d96e2e62d98057354b99ebd45e639d924ac1c296c7655267ca9f6
7
+ data.tar.gz: c6e5d2642f77041cf2fd85936ac5f9c2ab8bf583bfcbdb33bcbdb6ed65cb9dacdf8bda95c68a6e564688042e028bef64dbc379e49eb9771a76b0889dd7ff0aed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- core_extend (0.1.2)
4
+ core_extend (0.1.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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 "#{int_str}.#{point_str}" if int_str.to_i<10000
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 "#{int_str}.#{point_str}" if int_str.length<3
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
- "#{int_str}.#{point_str}"
39
+ return_value.call
34
40
  end
35
41
  end
36
42
  end
@@ -0,0 +1,4 @@
1
+ class Integer
2
+ include CoreExtend::FloatModule
3
+
4
+ end
@@ -1,3 +1,3 @@
1
1
  module CoreExtend
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
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.3
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: