Class: ForgetTable::WeightedDistribution

Inherits:
Object
  • Object
show all
Defined in:
lib/forget_table/weighted_distribution.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#binsObject (readonly)

Returns the value of attribute bins.



4
5
6
# File 'lib/forget_table/weighted_distribution.rb', line 4

def bins
  @bins
end

#nameObject (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_namesObject



15
16
17
# File 'lib/forget_table/weighted_distribution.rb', line 15

def bin_names
  bins.keys
end

#hits_countObject



19
20
21
# File 'lib/forget_table/weighted_distribution.rb', line 19

def hits_count
  values.inject(:+).to_i
end

#valuesObject



11
12
13
# File 'lib/forget_table/weighted_distribution.rb', line 11

def values
  bins.values
end