pickup 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,9 +63,9 @@ class Pickup
63
63
  item = list.detect do |k,v|
64
64
  val = func.call v[:value]
65
65
  num = func.call n
66
- val >= num && !(uniq && v[:picked])
66
+ (val >= num) && !(uniq && v[:picked])
67
67
  end
68
- item ||= list.first{ |k,v| !v[:picked] }
68
+ item ||= list.detect{ |k,v| !v[:picked] }
69
69
  raise "No items left" unless item
70
70
  key = item[0]
71
71
  list[key][:picked] = true if uniq
@@ -1,3 +1,3 @@
1
1
  class Pickup
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -14,6 +14,7 @@ describe Pickup do
14
14
  }
15
15
  @func = Proc.new{ |a| a }
16
16
  @pickup = Pickup.new(@list)
17
+ @pickup2 = Pickup.new(@list, true)
17
18
  end
18
19
 
19
20
  it "should pick correct ammount of items" do
@@ -49,4 +50,9 @@ describe Pickup do
49
50
  @ml.get_random_item(30).must_equal "selmon"
50
51
  end
51
52
  end
53
+
54
+ it "should take 7 different fish" do
55
+ items = @pickup2.pick(7)
56
+ items.uniq.size.must_equal 7
57
+ end
52
58
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pickup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: