class GreenMidget::Countable

Attributes

key[RW]

Public Class Methods

[](key)
Alias for: new
new(key) click to toggle source
# File lib/green_midget/models/countable.rb, line 25
def initialize(key)
  @key = self.class.prefix + key
end
Also aliased as: []
objects(keys) click to toggle source
# File lib/green_midget/models/countable.rb, line 32
def objects(keys)
  keys.map { |key| new(key) }
end

Public Instance Methods

[](category) click to toggle source
# File lib/green_midget/models/countable.rb, line 37
def [](category)
  Records[record_key(category)].to_f
end
log_ratio() click to toggle source
# File lib/green_midget/models/countable.rb, line 41
def log_ratio
  Math::log(probability_for(ALTERNATIVE) / probability_for(NULL))
end
record_key(category) click to toggle source
# File lib/green_midget/models/countable.rb, line 45
def record_key(category)
  "#{self.key}::#{category}_count"
end