class Myco::DEV::Counter
Public Class Methods
coll()
click to toggle source
# File lib/myco/dev/counter.rb, line 6 def coll @coll ||= begin at_exit { print! } Hash.new(0) end end
count(*items)
click to toggle source
# File lib/myco/dev/counter.rb, line 13 def count(*items) coll[items] += 1 end
print!()
click to toggle source
# File lib/myco/dev/counter.rb, line 17 def print! STDOUT.puts "#{self} report:" coll.to_a.sort_by { |x| x.last }.each do |key,val| STDOUT.puts " #{val} : #{key.inspect}" end end