weighted_list 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/weighted_list.rb +2 -1
- data/lib/weighted_list/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a8ad1ca4f95df917bd99628170dfc4b7571633216e6b3637504135ab3fb759e
|
4
|
+
data.tar.gz: cff9e4ee6597b77a60cbbd04abfe39f84cce89ed787d898a3a627ad5638664ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba0ec48511362ad411da0188ed6680fd58edf866141a23bfe2d71c70b51d4f74965c930187ed27537d27a39466516d93e47bdcff8498700a7561091f0e4b86cc
|
7
|
+
data.tar.gz: c0f9c8f9a7058396fa711973f04abe04de40bf09f03ac08f6ddadfac3a94c131fc6e563ecb36171918c170a7e59b4d5d9e59dafce39c07a17ad422cb3eb65dbc
|
data/Gemfile.lock
CHANGED
data/lib/weighted_list.rb
CHANGED
@@ -23,9 +23,10 @@ class WeightedList
|
|
23
23
|
return select_item(hash, random: random).selected unless quantity
|
24
24
|
quantity.times.each_with_object(initial_memo) do |_index, memo|
|
25
25
|
result = select_item(memo[:current_list], random: random)
|
26
|
+
return memo[:selected] if result.selected.nil?
|
26
27
|
memo[:selected].push(result.selected)
|
27
28
|
memo[:current_list] = (with_replacement ? hash : result.remaining)
|
28
|
-
end[:selected]
|
29
|
+
end[:selected]
|
29
30
|
end
|
30
31
|
|
31
32
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weighted_list
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jayson Virissimo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|