class Counter def initialize() @characters = Hash.new(0) end def read() @text = IO.read("text.txt") end def count_chars @text.each_byte do |ch| @characters[ch] +=1 end end def report @characters.each do |key, value| puts "#{key.chr} (#{key}) occurs #{value} times" end end end