weighted_list 0.2.0 → 0.3.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: 8c25829111b4df390b8c30377bd879709f9e9c680498bc6687feaad4f30c21e4
4
- data.tar.gz: 5d6a2c7cd763d2bb4be4c55bbc7c5d5925a108b68dbf16ae1a9ee5b6769fa16b
3
+ metadata.gz: 925e9f3a1fba2c35de1dd9825b28702353798b5a4cbdf63e603fab141926577d
4
+ data.tar.gz: cc4b917a7322de3eeddc18f00910d432d731bc24957a52bce4041a6f17ee996a
5
5
  SHA512:
6
- metadata.gz: fbbcd08a9bdfeffdd2779710d85aaa18497a72d3bcd8daf54e1a21cdd5978f2a12bde3d4144d263ad571ddaab1ea7e5ce256a536edd7ee6b6981a28b1781596c
7
- data.tar.gz: f82c14b44bb1fbf8954978ec2a39769cb3586c40b24487fecb5c7a43effb5af838688fe0f95e866c1aaf4e29598648add8a71da3c33a42941d3c5e1605a3ab79
6
+ metadata.gz: cefce48130c7db1b3d7a8f2c1b167f5e49ffbad70a7133142f1e70a41ec70326536ad71b1efc4d27f7716330af33af704e57e427f073fb2f268e1faa8ab7bab0
7
+ data.tar.gz: 3ae2f07dbdf47e3a41d5f31453b242ec0a5bc0cb4596f240aa7ed27e74a81296a236af31337299fb9f48fa8c87c910339b12052f1f201827cc3c9e83bc910831
data/.gitignore CHANGED
@@ -8,4 +8,3 @@
8
8
  /tmp/
9
9
  .rspec_status
10
10
  .DS_Store
11
- Gemfile.lock
@@ -0,0 +1,35 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ weighted_list (0.3.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.3)
10
+ rake (10.5.0)
11
+ rspec (3.6.0)
12
+ rspec-core (~> 3.6.0)
13
+ rspec-expectations (~> 3.6.0)
14
+ rspec-mocks (~> 3.6.0)
15
+ rspec-core (3.6.0)
16
+ rspec-support (~> 3.6.0)
17
+ rspec-expectations (3.6.0)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.6.0)
20
+ rspec-mocks (3.6.0)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.6.0)
23
+ rspec-support (3.6.0)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ bundler (~> 1.16)
30
+ rake (~> 10.0)
31
+ rspec (~> 3.0)
32
+ weighted_list!
33
+
34
+ BUNDLED WITH
35
+ 1.16.5
data/README.md CHANGED
@@ -26,7 +26,8 @@ Or install it yourself as:
26
26
 
27
27
  ## Usage
28
28
  ```ruby
29
- list = WeightedList.new({ eastern: 150, central: 92, mountain: 21, pacific: 53 })
29
+ hash = { eastern: 150, central: 92, mountain: 21, pacific: 53 }
30
+ list = WeightedList[hash]
30
31
 
31
32
  list.sample # => :pacific
32
33
  list.sample(1) # => [:central]
@@ -7,6 +7,10 @@ require 'weighted_list/sampler'
7
7
  class WeightedList
8
8
  include Enumerable
9
9
 
10
+ def self.[](collection)
11
+ new(collection)
12
+ end
13
+
10
14
  def initialize(collection)
11
15
  @hash = Normalizer.call(collection)
12
16
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class WeightedList
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weighted_list
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jayson Virissimo