hazard 1.3.1 → 1.3.2

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
  SHA1:
3
- metadata.gz: ccb0217f3b63ffd8b667acb3ca8250145540120e
4
- data.tar.gz: c0b892b16371e60d4e4a0c71e42c5319bba34ffb
3
+ metadata.gz: 8ad65f2c9f179677ed7f59455fb1836af756e5d1
4
+ data.tar.gz: 2f8d5c6da1b99735448fe3ab51f5bb544f9cc6ce
5
5
  SHA512:
6
- metadata.gz: 60f0e90c335352e3e2f9deac1c18f247bcd791727d751309fe25a41ce2f66d9f816e60e4c7c6bb9db9b3b2f90fffb2bd36a9463dd006e5373338a7944f20a955
7
- data.tar.gz: 97cb2d1b0c0cad4616f7e0ab2b8d682fced257c545117b2bb488a66aad73f9a36f479926cb24c8b327e6102855aee9cc97cd75a99b9af519ccd114d718d44d0a
6
+ metadata.gz: a6cb6d3620502079175076aab7757136eb872be30da81357bf84f2ad268180dbc38b441e86059562de36ff1a34f7782dd056e2ba50edc7fe175496806a4ebe18
7
+ data.tar.gz: 1be600fddf5135d8223317612eb7f03388e683c9195911be18d48b298ff9c607de1ae7952163dafcff3317fbbe57929618664c4133a335208003d5efc6328be8
data/Gemfile CHANGED
@@ -6,5 +6,5 @@ gemspec
6
6
  group :test do
7
7
  gem 'codeclimate-test-reporter', '~> 1.0.0'
8
8
  gem 'mocha'
9
- gem 'simplecov'
9
+ gem 'simplecov', '0.17.1', require: false
10
10
  end
data/README.md CHANGED
@@ -28,7 +28,7 @@ Hazard is a very simple dice library for ruby that allows you to :
28
28
  Add this line to your application's Gemfile:
29
29
 
30
30
  ```ruby
31
- gem 'hazard', '~> 1.3', '>= 1.3.1'
31
+ gem 'hazard', '>= 1.3.1'
32
32
  ```
33
33
 
34
34
  And then execute:
data/hazard.gemspec CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.require_paths = ['lib']
26
26
 
27
27
  # spec.add_development_dependency 'bundler', '~> 1.13'
28
- spec.add_development_dependency 'rake', '~> 10.0'
28
+ spec.add_development_dependency 'rake', '~> 13.0'
29
29
  spec.add_development_dependency 'minitest', '~> 5.0'
30
30
 
31
31
  spec.required_ruby_version = '>= 2.0'
@@ -1,3 +1,3 @@
1
1
  class Hazard
2
- VERSION = '1.3.1'
2
+ VERSION = '1.3.2'
3
3
  end
@@ -7,12 +7,12 @@ class WeightedTable
7
7
 
8
8
  BASE_WEIGHT = 0
9
9
 
10
- # Initialize a WeightedTable
11
- # setting floating_points to true indicate that you will work with floating points rather than integers.
10
+ # Initialize a WeightedTable
11
+ # setting floating_points to true indicate that you will work with floating points rather than integers.
12
12
  def initialize( floating_points: false )
13
13
  @weights = []
14
14
  @max_weight = BASE_WEIGHT
15
- @floating_points = floating_points
15
+ @floating_points = floating_points
16
16
  end
17
17
 
18
18
  # Load a WeightedTable with data
@@ -32,21 +32,21 @@ class WeightedTable
32
32
  def from_weighted_table( table )
33
33
  raise 'Table must contain at least one element' if table.empty?
34
34
 
35
- # We may call this method many time for an existing object, so we must clear it
36
- @weights.clear
35
+ # We may call this method many time for an existing object, so we must clear it
36
+ @weights.clear
37
37
 
38
38
  base = BASE_WEIGHT
39
- w = nil
39
+ w = nil
40
40
 
41
41
  table.each do |weight, data|
42
42
  w = base + weight
43
- @weights << [base, w, data]
43
+ @weights << [base, w, data]
44
44
  base = w
45
- end
45
+ end
46
46
 
47
- @max_weight = w
47
+ @max_weight = w
48
48
 
49
- # p @weights, @max_weight
49
+ # p @weights, @max_weight
50
50
 
51
51
  self
52
52
  end
@@ -65,18 +65,18 @@ class WeightedTable
65
65
  # @return [Object] a random object given at the building of the table.
66
66
  def sample
67
67
 
68
- # ... means that @max_weight is excluded
69
- if @floating_points
70
- r = Kernel.rand( 0.0...@max_weight.to_f )
71
- else
72
- r = Kernel.rand( 0...@max_weight )
73
- end
68
+ # ... means that @max_weight is excluded
69
+ if @floating_points
70
+ r = Kernel.rand( 0.0...@max_weight.to_f )
71
+ else
72
+ r = Kernel.rand( 0...@max_weight )
73
+ end
74
74
 
75
- # p r
75
+ # p r
76
76
 
77
77
  @weights.each do |base_weight, max_weight, data|
78
- return data if r >= base_weight && r < max_weight
79
- end
78
+ return data if r >= base_weight && r < max_weight
79
+ end
80
80
 
81
81
  raise 'Rand not in key range'
82
82
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hazard
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cédric ZUGER
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-14 00:00:00.000000000 Z
11
+ date: 2020-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '10.0'
19
+ version: '13.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '10.0'
26
+ version: '13.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement