class Scorecard::Card

Attributes

user[R]

Public Class Methods

new(user) click to toggle source
# File lib/scorecard/card.rb, line 4
def initialize(user)
  @user = user
end

Public Instance Methods

badges() click to toggle source
# File lib/scorecard/card.rb, line 8
def badges
  @badges ||= begin
    identifiers = Scorecard::UserBadge.for_user(user).pluck(:badge).uniq
    identifiers.collect { |identifier|
      Scorecard::AppliedBadge.new identifier.to_sym, user
    }
  end
end
level() click to toggle source
# File lib/scorecard/card.rb, line 17
def level
  @level ||= begin
    record = Scorecard::Level.for_user(user)
    record.nil? ? Scorecard.levels.call(user) : record.amount
  end
end
points() click to toggle source
# File lib/scorecard/card.rb, line 24
def points
  @points ||= Scorecard::Point.for_user(user).sum(:amount)
end
progress() click to toggle source
# File lib/scorecard/card.rb, line 28
def progress
  @progress ||= Scorecard::Progress.for_user(user).collect(&:amount).sum
end
remaining_progressions() click to toggle source
# File lib/scorecard/card.rb, line 32
def remaining_progressions
  @remaining_progressions ||= Scorecard.progressions.without(
    Scorecard::Progress.for_user(user).collect(&:identifier).
      collect(&:to_sym)
  )
end