Class: Osm::Badges::DueBadges

Inherits:
Model
  • Object
show all
Defined in:
lib/osm/badges.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#<, #<=, #<=>, #>, #>=, #between?, #changed_attributes, configure, #reset_changed_attributes, #to_i

Constructor Details

#initializeObject

Initialize a new DueBadges

Parameters:

  • attributes (Hash)

    The hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)



# File 'lib/osm/badges.rb', line 130

Instance Attribute Details

#badge_namesHash

Returns name to display for each of the badges.

Returns:

  • (Hash)

    name to display for each of the badges



105
# File 'lib/osm/badges.rb', line 105

attribute :badge_names, :default => {}

#by_memberHash

Returns the due badges grouped by member.

Returns:

  • (Hash)

    the due badges grouped by member



105
# File 'lib/osm/badges.rb', line 105

attribute :badge_names, :default => {}

#member_namesHash

Returns the name to display for each member.

Returns:

  • (Hash)

    the name to display for each member



105
# File 'lib/osm/badges.rb', line 105

attribute :badge_names, :default => {}

Instance Method Details

#empty?Boolean

Check if there are no badges due

Returns:

  • (Boolean)


137
138
139
# File 'lib/osm/badges.rb', line 137

def empty?
  return by_member.empty?
end

#totalsHash

Calculate the total number of badges needed

Returns:

  • (Hash)

    the total number of each badge which is due



143
144
145
146
147
148
149
150
151
152
# File 'lib/osm/badges.rb', line 143

def totals()
  totals = {}
  by_member.each do |member_name, badges|
    badges.each do |badge|
      totals[badge] ||= 0
      totals[badge] += 1
    end
  end
  return totals
end