I have an array of objects, and I want to take one of the methods to return it into 1 single line.
here is my array
def set
@seconds = Counter.new('Seconds')
@minutes = Counter.new('Minutes')
@hours = Counter.new('Hours')
@time = [@seconds, @minutes, @hours]
end
and here is the method I'm trying to print in the Counter class
def count
@counts
end
Here's my attempt
def read
reverse = @time.reverse
@time.each do |t|
return '%02d' %t.count.to_s.join(":")
end
end
(I also want them to be in 00, 01 formats, hence the '%02d')
.join doesn't seem to work (I'm guessing it works with arrays but not methods of an array?
any help will be appreciated!