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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: deccd69f64bb1d8425b9f5c4ccecf01e9e567cd21cbbde7a0152001cfe33ab39
4
- data.tar.gz: 326bb826fcd77d551084ddf77addf7b78710d3e82236684ddb5cb1a29d40eb09
3
+ metadata.gz: 0a8ad1ca4f95df917bd99628170dfc4b7571633216e6b3637504135ab3fb759e
4
+ data.tar.gz: cff9e4ee6597b77a60cbbd04abfe39f84cce89ed787d898a3a627ad5638664ad
5
5
  SHA512:
6
- metadata.gz: 93138c4eca3022ec6eea9f299a23b7eaa55d4f79fad3d989e03907db748709703fe7a12dba7ccde3785c25756b39e482d50d1704b77b615277980d30f6581476
7
- data.tar.gz: 3d915f260d8cdff3cc23d703f6bfea37e5289316f9e113b663baffbbc6b7fa67d8c4df341075e308a21f3699fc0f9e5c6bef8da25675ac25f52fa1faaf934e68
6
+ metadata.gz: ba0ec48511362ad411da0188ed6680fd58edf866141a23bfe2d71c70b51d4f74965c930187ed27537d27a39466516d93e47bdcff8498700a7561091f0e4b86cc
7
+ data.tar.gz: c0f9c8f9a7058396fa711973f04abe04de40bf09f03ac08f6ddadfac3a94c131fc6e563ecb36171918c170a7e59b4d5d9e59dafce39c07a17ad422cb3eb65dbc
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- weighted_list (0.4.0)
4
+ weighted_list (0.5.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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].compact
29
+ end[:selected]
29
30
  end
30
31
 
31
32
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class WeightedList
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
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.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-10-28 00:00:00.000000000 Z
11
+ date: 2018-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler