any idea how I can display headers using % for formatting? I does nothing in class method but works nicely in instance method
class Stats
attr_accessor :type, :count;
def initialize type
@type = type
@count = 0
end
def self.display
"%s %4s " % ["header1",'header2']
#puts 'headers'
ObjectSpace.each_object(Stats) { |o|
puts o
}
end
def to_s
"%-9s %4d " % [@type, @count]
end
end
videos = Stats.new 'Videos'
videos.count = 3
article = Stats.new 'Article'
webinars = Stats.new 'Webinars'
Stats.display