module Lingo::Reportable

Provides counters.

Public Instance Methods

add(key, val) click to toggle source
# File lib/lingo/reportable.rb, line 41
def add(key, val)
  @reportable_hash[key] += val
end
get(key) click to toggle source
# File lib/lingo/reportable.rb, line 49
def get(key)
  @reportable_hash[key]
end
inc(key) click to toggle source
# File lib/lingo/reportable.rb, line 37
def inc(key)
  @reportable_hash[key] += 1
end
init_reportable(prefix = nil) click to toggle source
# File lib/lingo/reportable.rb, line 32
def init_reportable(prefix = nil)
  @reportable_hash   = Hash.new(0)
  @reportable_prefix = prefix ? "#{prefix}: " : ''
end
report() click to toggle source
# File lib/lingo/reportable.rb, line 53
def report
  q = @reportable_prefix
  @reportable_hash.each_with_object({}) { |(k, v), r| r["#{q}#{k}"] = v }
end
set(key, val) click to toggle source
# File lib/lingo/reportable.rb, line 45
def set(key, val)
  @reportable_hash[key] = val
end