dicey 0.16.1 → 0.16.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86d934c5cf9455e15c42f84abe397c7c32ada670512969decd4e44c9eef1841f
4
- data.tar.gz: bcba52a9d0e1bbb0308db1025ba2c723bf963aa02b323b631538bdbc722144e2
3
+ metadata.gz: 5926d48370da981038bcc841fda2d3b1ea995d033f02f2373a097be5a510020a
4
+ data.tar.gz: 1692a73044f83c7fa8889b86f2ad812cb40e1f9faf26feb94522457872544108
5
5
  SHA512:
6
- metadata.gz: 46d142b6caed4432f4adede2d34214498e1bbfe02aadca4aaa58709c5fa9ce15d4c71e75ce37f599752c10f334da0acb616c7278ba5076d1ed4746b36fb7b35b
7
- data.tar.gz: 14ad44e95941c5e7d94c71968a9f84105d1f6a64b50ab551c94ddea247dda77a80e5f83e2566bdea76ec912b799f1a05e3bbb160d0cc1b3af5211c795bc2b415
6
+ metadata.gz: 35e956615ff78b7007a7333172181f0c6666f06a5ab61cf2355c7744f1cff92e01fe9f1ad877c62b853bda9789de02d0a9a76ea13404e2e7a9b2711b7dc6c3df
7
+ data.tar.gz: '0858e35f03ddd80ef754fde0276f33999124040fd499193c5f7eb2fe0c933c1c24677a2ea25e8ceea0259055469dd9076c6def50cde665267eb88386de8d7659'
@@ -25,6 +25,10 @@ module Dicey
25
25
  # Possible values for +result_type+ argument in {#call}.
26
26
  RESULT_TYPES = %i[frequencies probabilities].freeze
27
27
 
28
+ # Calculate distribution (probability mass function) for the list of dice.
29
+ #
30
+ # Returns empty hash for an empty list of dice.
31
+ #
28
32
  # @param dice [Enumerable<AbstractDie>]
29
33
  # @param result_type [Symbol] one of {RESULT_TYPES}
30
34
  # @param options [Hash{Symbol => Any}] calculator-specific options,
@@ -57,11 +61,15 @@ module Dicey
57
61
 
58
62
  # Heuristic complexity of the calculator, used to determine best calculator.
59
63
  #
64
+ # Returns 0 for an empty list of dice.
65
+ #
60
66
  # @see AutoSelector
61
67
  #
62
68
  # @param dice [Enumerable<AbstractDie>]
63
69
  # @return [Integer]
64
70
  def heuristic_complexity(dice)
71
+ return 0 if dice.empty?
72
+
65
73
  calculate_heuristic(dice.length, dice.map(&:sides_num).max).to_i
66
74
  end
67
75
 
data/lib/dicey/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dicey
4
- VERSION = "0.16.1"
4
+ VERSION = "0.16.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dicey
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.1
4
+ version: 0.16.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandr Bulancov
@@ -77,9 +77,9 @@ licenses:
77
77
  metadata:
78
78
  homepage_uri: https://github.com/trinistr/dicey
79
79
  bug_tracker_uri: https://github.com/trinistr/dicey/issues
80
- documentation_uri: https://rubydoc.info/gems/dicey/0.16.1
81
- source_code_uri: https://github.com/trinistr/dicey/tree/v0.16.1
82
- changelog_uri: https://github.com/trinistr/dicey/blob/v0.16.1/CHANGELOG.md
80
+ documentation_uri: https://rubydoc.info/gems/dicey/0.16.2
81
+ source_code_uri: https://github.com/trinistr/dicey/tree/v0.16.2
82
+ changelog_uri: https://github.com/trinistr/dicey/blob/v0.16.2/CHANGELOG.md
83
83
  rubygems_mfa_required: 'true'
84
84
  post_install_message:
85
85
  rdoc_options: