ok-extensions 1.0.7 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,4 +11,8 @@ class Array
11
11
 
12
12
  flattened
13
13
  end
14
- end
14
+
15
+ def pick
16
+ self[Kernel.rand(size)]
17
+ end
18
+ end
@@ -34,3 +34,10 @@ class Object
34
34
  alias :myself :me
35
35
  alias :i :me
36
36
  end
37
+
38
+ # in?
39
+ class Object
40
+ def in?(array)
41
+ array.include? self
42
+ end
43
+ end
data/lib/ok_extensions.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class OkExtensions
2
- VERSION = '1.0.7'
2
+ VERSION = '1.0.10'
3
3
  end
4
4
 
5
5
  $LOAD_PATH << File.dirname(__FILE__)
@@ -9,4 +9,11 @@ class TestArray < Test::Unit::TestCase
9
9
 
10
10
  assert_equal [1, 2, 3, [4, 5, 6, [7, 8, 9]], 10, 11, 12, 13, 14, 15], a.flatten_once
11
11
  end
12
- end
12
+
13
+
14
+ def test_pick
15
+ assert_equal 1, [1].pick
16
+ assert_equal nil, [].pick
17
+ [1,2,3,4,5].pick
18
+ end
19
+ end
@@ -20,9 +20,15 @@ class TestObject < Test::Unit::TestCase
20
20
  end
21
21
  end
22
22
 
23
+ def test_in
24
+ assert 5.in? [9,5,100]
25
+ assert :a.in? [:c,:b,:a]
26
+ assert ! 1.in?([2,3,4])
27
+ end
28
+
23
29
  def explicit_test_benchmark_safe_nil
24
30
  Benchmark.bm do |x|
25
31
  x.report { 10000.times { nil._?.abc } }
26
32
  end
27
33
  end
28
- end
34
+ end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: ok-extensions
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.7
7
- date: 2007-12-23 00:00:00 +07:00
6
+ version: 1.0.10
7
+ date: 2008-02-13 00:00:00 +07:00
8
8
  summary: The author was too lazy to write a summary
9
9
  require_paths:
10
10
  - lib