rmtools 2.4.7 → 2.4.8

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: e1f4419c1717d05e6a3d242549d07990f8d78ed6
4
- data.tar.gz: 58638b18e7c04d78fcd70c410570db7c2ec93843
3
+ metadata.gz: 1e8e12082b944e9b2b5448e9fe05a69da97e39b7
4
+ data.tar.gz: 32b3623bfcd26012dab4266b25fc9a17cd7fa53c
5
5
  SHA512:
6
- metadata.gz: 9cbf952f1d4d010ea366cdafbacdff9e0da4d770d239b0f2c73d9043143199de3f903374d04824d218d2bcfe03e1b0740397453394c7443435462c81e7e11b47
7
- data.tar.gz: c6012f35f2d7a64066da100e39c10e35fa63b67daf8f87dac49e579e12988a057534466e57d02bfb45bf7f75e326b57a957e47625099fbb4bc01fdd17108f5f3
6
+ metadata.gz: cc3701b9c5bf250d8855f66fddd0a5a43b4605be9f407508fc55eb84c65b60d7da0405f95ede5bf4d96935d99a4e305dba23c9e3a4f53d6a146f24d6aba4fa88
7
+ data.tar.gz: d37e09f9fca2c176e77ec84a3547ada06eed0099fc68c479d176c9ba4e11a8fb52398572454d820fc59ce8bef95bb9a733d9056bb3ea0ce84b62e89337ee653b
@@ -1,20 +1,24 @@
1
1
  # encoding: utf-8
2
2
  module Enumerable
3
3
 
4
- def rand
5
- if block_given?
6
- h, ua = {}, to_a.uniq
7
- s = ua.size
8
- loop {
9
- i = Kernel.rand size
10
- if h[i]
11
- return if h.size == s
12
- elsif yield(e = ua[i])
13
- return e
14
- else h[i] = true
15
- end
16
- }
17
- else to_a[Kernel.rand(size)]
4
+ def rand(*args)
5
+ if args.empty?
6
+ if block_given?
7
+ h, ua = {}, to_a.uniq
8
+ s = ua.size
9
+ loop {
10
+ i = Kernel.rand size
11
+ if h[i]
12
+ return if h.size == s
13
+ elsif yield(e = ua[i])
14
+ return e
15
+ else h[i] = true
16
+ end
17
+ }
18
+ else to_a[Kernel.rand(size)]
19
+ end
20
+ else
21
+ Kernel.rand(*args)
18
22
  end
19
23
  end
20
24
 
@@ -1,3 +1,3 @@
1
1
  module RMTools
2
- VERSION = '2.4.7'
2
+ VERSION = '2.4.8'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rmtools
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.7
4
+ version: 2.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Baev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-15 00:00:00.000000000 Z
11
+ date: 2015-02-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: RMTools is a collection of helpers for debug, text/array/file processing
14
14
  and simply easing a coding process