ranking 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,4 +21,8 @@ module Ranking::InstanceMethods
21
21
  scores[object] = value
22
22
  self
23
23
  end
24
+
25
+ def [](*args)
26
+ to_a[*args]
27
+ end
24
28
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "ranking"
5
- gem.version = "0.1.0"
5
+ gem.version = "0.1.1"
6
6
  gem.summary = %q{Sorted sets using scores}
7
7
  gem.description = %q{Extends Set with a score. Sorts by score on #to_a, #each, etc}
8
8
  gem.license = "MIT"
@@ -81,4 +81,22 @@ describe Ranking::InstanceMethods do
81
81
  expect { @instance.score(:foo) }.to raise_error(ArgumentError)
82
82
  end
83
83
  end
84
+
85
+ describe "#[]" do
86
+ before(:each) do
87
+ @instance.score(:foo, 5).score(:bar, 4).score(:baz, 3).score(:qux,2)
88
+ end
89
+
90
+ it "indexes" do
91
+ @instance[1].should == :bar
92
+ end
93
+
94
+ it "slices with .." do
95
+ @instance[1..2].should == [:bar, :baz]
96
+ end
97
+
98
+ it "slices with ..." do
99
+ @instance[1...3].should == [:bar, :baz]
100
+ end
101
+ end
84
102
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ranking
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -64,7 +64,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
64
64
  version: '0'
65
65
  segments:
66
66
  - 0
67
- hash: 2123784621627134409
67
+ hash: 1644303560493458915
68
68
  required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  none: false
70
70
  requirements:
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  version: '0'
74
74
  segments:
75
75
  - 0
76
- hash: 2123784621627134409
76
+ hash: 1644303560493458915
77
77
  requirements: []
78
78
  rubyforge_project:
79
79
  rubygems_version: 1.8.23