counter = [0, 0, 0, 0, 0, 0] class Count def initialize(data) @data = data end def acount if @data == 1 counter[0] = counter[0].to_i+1 end end end one = (rand(5).to_i+1) Count.new(one).acount puts counter[0]