# File lib/benelux/stats.rb, line 49 def +(other) if !other.is_a?(Benelux::Stats) raise TypeError, "can't convert #{other.class} into Stats" end s = self.clone other.names.each do |name| s.add_group name s.group(name) << other.group(name) end s end
# File lib/benelux/stats.rb, line 33 def add_groups(*args) args.flatten.each do |meth| next if has_group? meth @names << meth self.class.send :attr_reader, meth (g = Benelux::Stats::Group.new).name = meth instance_variable_set("@#{meth}", g) end end
# File lib/benelux/stats.rb, line 18 def clear each { |g| g.clear } @names.clear end
# File lib/benelux/stats.rb, line 13 def create_zero_group(name) g = Benelux::Stats::Group.new g.name = name g end
Each group
# File lib/benelux/stats.rb, line 26 def each(&blk) @names.each { |name| blk.call(group(name)) } end
Each group name, group
# File lib/benelux/stats.rb, line 30 def each_pair(&blk) @names.each { |name| blk.call(name, group(name)) } end
# File lib/benelux/stats.rb, line 10 def group(name) @names.member?(name) ? self.send(name) : create_zero_group(name) end
# File lib/benelux/stats.rb, line 46 def has_group?(name) @names.member? name end
Generated with the Darkfish Rdoc Generator 2.