core_extend 0.1.4 → 0.1.5

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: fb28ccf2b597a267a05f52d59d3e1f955b1b9897
4
- data.tar.gz: 47288a5a6295e46269ebc4958e1734676f0d80af
3
+ metadata.gz: 6e9d56ced4bc7c5adbdb561052adb0ce9de631a3
4
+ data.tar.gz: f19b929050ede5c05232e0ab36ba608cd71f3122
5
5
  SHA512:
6
- metadata.gz: f6d485f9f03937d27fc81b2fb19325d1b324e85079f2dbc1cb143a100d25d499144623c29f7d96e2e62d98057354b99ebd45e639d924ac1c296c7655267ca9f6
7
- data.tar.gz: c6e5d2642f77041cf2fd85936ac5f9c2ab8bf583bfcbdb33bcbdb6ed65cb9dacdf8bda95c68a6e564688042e028bef64dbc379e49eb9771a76b0889dd7ff0aed
6
+ metadata.gz: 1db03188c6476bd71bbdc82f6b84aa47d88486fe7c94e15042b6d9325c3c299388926661d8a18592ef5bc92c4a60524185e57af6b047ddea7b6f75bc359c4766
7
+ data.tar.gz: b72c61facca1c5c34d40f0326f96f8dd7e0d05c1264131c652009c5012f87b3e20113bdece3a0b6cb926bc6a2b1c08cfcee2b48d5e89e19ab3ad8f23d5a7ef04
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- core_extend (0.1.3)
4
+ core_extend (0.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,10 +1,11 @@
1
1
  # CoreExtend
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/core_extend`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ gem主要包括数组的遍历、浮点数的小数点精度的确定、金钱显示、随机字符串等常用操作
6
4
 
7
5
  ## Installation
6
+ Add this line to `config/application.rb`
7
+
8
+ require 'core_extend'
8
9
 
9
10
  Add this line to your application's Gemfile:
10
11
 
@@ -20,9 +21,51 @@ Or install it yourself as:
20
21
 
21
22
  $ gem install core_extend
22
23
 
23
- ## Usage
24
+ ## Array
25
+
26
+ ### every
27
+ ```ruby
28
+ it 'every' do
29
+ (1..20).to_a.every(3) { |a, b, c|
30
+ p "#{a},#{b},#{c}"
31
+ }
32
+ end
33
+ #=>"1,2,3"
34
+ #=>"4,5,6"
35
+ #=>"7,8,9"
36
+ #=>"10,11,12"
37
+ #=>"13,14,15"
38
+ #=>"16,17,18"
39
+ #=>"19,20,"
40
+ ```
41
+
42
+ ## Float
43
+
44
+ ###decimal_point
45
+ ```ruby
46
+ 3.2268.decimal_point(2)
47
+ #=>3.23
48
+ ```
49
+ ###to_money
50
+ ```ruby
51
+ 123456789.456.to_money #=>"123,456,789.46"
52
+ 32005487.45.to_money('text') #=>"3200.55万"
53
+ 2332005487.45.to_money('text',4) #=>"23.3201亿"
54
+ 2332005487.45.to_money('text',0) #=>"23亿"
55
+ 2332005487.45.to_money('num',2) #=>"2,332,005,487.45"
56
+ 2332005487.45.to_money('num',0) #=>"2,332,005,487"
57
+ 1.to_money #=>"1.0"
58
+ ```
59
+
60
+ ## Random
61
+
62
+ ###rand_str
63
+ ```ruby
64
+ str = Random.rand_str(32)
65
+ p str
66
+ #=>"tdb1hruwxd8p0z5qtdl7pvhva5uxbru9"
67
+ ```
24
68
 
25
- TODO: Write usage instructions here
26
69
 
27
70
  ## Development
28
71
 
@@ -0,0 +1,7 @@
1
+ class Random
2
+
3
+ #随机长度的字符串
4
+ def self.rand_str(length)
5
+ length.times.inject('') { |acc, i| acc+=(('a'..'z').to_a+('0'..'9').to_a)[(i+Random.rand(1000))%36]; acc }
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module CoreExtend
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: core_extend
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - saxer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-22 00:00:00.000000000 Z
11
+ date: 2015-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -61,6 +61,7 @@ files:
61
61
  - lib/core_extend/float.rb
62
62
  - lib/core_extend/float_module.rb
63
63
  - lib/core_extend/integer.rb
64
+ - lib/core_extend/random.rb
64
65
  - lib/core_extend/version.rb
65
66
  homepage: https://github.com/mumaoxi/core_extend
66
67
  licenses: