Class: ForgetTable::WeightedDistribution
- Inherits:
-
Object
- Object
- ForgetTable::WeightedDistribution
- Defined in:
- lib/forget_table/weighted_distribution.rb
Instance Attribute Summary collapse
-
#bins ⇒ Object
readonly
Returns the value of attribute bins.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #bin_names ⇒ Object
- #hits_count ⇒ Object
-
#initialize(name:, bins:) ⇒ WeightedDistribution
constructor
A new instance of WeightedDistribution.
- #values ⇒ Object
Constructor Details
#initialize(name:, bins:) ⇒ WeightedDistribution
Returns a new instance of WeightedDistribution.
6 7 8 9 |
# File 'lib/forget_table/weighted_distribution.rb', line 6 def initialize(name:, bins:) @name = name @bins = bins end |
Instance Attribute Details
#bins ⇒ Object (readonly)
Returns the value of attribute bins.
4 5 6 |
# File 'lib/forget_table/weighted_distribution.rb', line 4 def bins @bins end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/forget_table/weighted_distribution.rb', line 4 def name @name end |
Instance Method Details
#bin_names ⇒ Object
15 16 17 |
# File 'lib/forget_table/weighted_distribution.rb', line 15 def bin_names bins.keys end |
#hits_count ⇒ Object
19 20 21 |
# File 'lib/forget_table/weighted_distribution.rb', line 19 def hits_count values.inject(:+).to_i end |
#values ⇒ Object
11 12 13 |
# File 'lib/forget_table/weighted_distribution.rb', line 11 def values bins.values end |