kanamei-keystone 0.0.25 → 0.0.26
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/keystone.rb +1 -1
- data/lib/keystone/core_ext/array.rb +13 -1
- metadata +1 -1
data/lib/keystone.rb
CHANGED
@@ -14,4 +14,16 @@ class Array
|
|
14
14
|
end
|
15
15
|
return ret
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
|
+
if RUBY_VERSION < '1.8.7'
|
19
|
+
def sample(count=1)
|
20
|
+
if count == 1
|
21
|
+
return at( rand( size ) )
|
22
|
+
elsif count < 1
|
23
|
+
return nil
|
24
|
+
else
|
25
|
+
return sort_by{rand}[0..count-1]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|