class TrackRecordReport::CalculatorWithUsers

A Calculator subclass which adds support for a hash of per-user Calculator instances accessed via user ID, as a string.

Public Class Methods

new() click to toggle source
# File lib/track_record_report.rb, line 122
def initialize
  super()
  @user_totals = {}
end

Public Instance Methods

user_total( user_id_str ) click to toggle source

Return a Calculator object for the given user (as a string database ID), or nil if there is no such user record for this cell.

# File lib/track_record_report.rb, line 130
def user_total( user_id_str )
  @user_totals[ user_id_str ]
end
user_total!( user_id_str ) click to toggle source

Return a Calculator object for the given user (as a string database ID), lazy-creating a new instance if need be.

# File lib/track_record_report.rb, line 137
def user_total!( user_id_str )
  @user_totals[ user_id_str ] ||= Calculator.new
end