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 +4 -4
- data/lib/rmtools/rand/enum.rb +18 -14
- data/lib/rmtools/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e8e12082b944e9b2b5448e9fe05a69da97e39b7
|
4
|
+
data.tar.gz: 32b3623bfcd26012dab4266b25fc9a17cd7fa53c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc3701b9c5bf250d8855f66fddd0a5a43b4605be9f407508fc55eb84c65b60d7da0405f95ede5bf4d96935d99a4e305dba23c9e3a4f53d6a146f24d6aba4fa88
|
7
|
+
data.tar.gz: d37e09f9fca2c176e77ec84a3547ada06eed0099fc68c479d176c9ba4e11a8fb52398572454d820fc59ce8bef95bb9a733d9056bb3ea0ce84b62e89337ee653b
|
data/lib/rmtools/rand/enum.rb
CHANGED
@@ -1,20 +1,24 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module Enumerable
|
3
3
|
|
4
|
-
def rand
|
5
|
-
if
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
|
data/lib/rmtools/version.rb
CHANGED
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.
|
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-
|
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
|