Heres what I have right now but it does reset the sec. to zero =A0it keep= s
going 61..62
def seconds_minutes_string(seconds_elapsed)
=A0seconds =3D seconds_elapsed % 59
=A0minutes =3D seconds / 60
=A0return minutes.to_s + ':' + seconds.to_s
end
I'm not sure what you mean that "it doesn't reset the sec to zero
def seconds_minutes_string(seconds_elapsed)
seconds =3D seconds_elapsed % 59
minutes =3D seconds / 60
return minutes.to_s + ':' + seconds.to_s
end
(55..65).map {|secs| seconds_minutes_string(secs)} # =3D> ["0:55",
"0:56", "0:57", "0:58", "0:0", "0:1", "0:2", "0:3", "0:4", "0:5",
"0:6"]
This should produce the right strings, I assume you wanted 1:01
instead of 1:1 for 1 minute and 1 second
def seconds_minutes_string(seconds_elapsed)
"%d:%02d" % [seconds_elapsed / 60, seconds_elapsed % 60]
end
(55..65).map {|secs| seconds_minutes_string(secs)} # =3D> ["0:55",
"0:56", "0:57", "0:58", "0:59", "1:00", "1:01", "1:02", "1:03",
"1:04", "1:05"]
--=20
Rick DeNatale
Blog:
http://talklikeaduck.denhaven2.com/
Twitter:
http://twitter.com/RickDeNatale
WWR:
http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn:
http://www.linkedin.com/in/rickdenatale