22# change.
33#
44# rate { Time.now.to_i }
5- # # 1243457076 (0.999/sec)
6- # # 1243457077 (0.999/sec)
7- # # 1243457078 (0.999/sec)
5+ # # 1243457076 (0.999/sec)
6+ # # 1243457077 (0.999/sec)
7+ # # 1243457078 (0.999/sec)
88def rate ( options = { } )
99 clear = `clear`
1010 defaults = {
@@ -23,11 +23,11 @@ def rate(options = {})
2323 rate = 0 unless rate . finite?
2424 last_value = values . last . first
2525 print clear if options [ :clear ]
26- time_to_zero =
26+ time_to_zero =
2727 if rate != 0 && last_value != 0 && ( rate . abs / rate ) != ( last_value . abs / last_value )
2828 "%.3f hours" % ( -last_value . to_f / rate / 60 / 60 )
2929 end
30-
30+
3131 puts "%15s (%s/sec) #{ time_to_zero } " % [ rate_delimiter ( last_value ) , rate_delimiter ( "%.3f" % rate ) ]
3232 puts unless options [ :clear ]
3333 sleep options [ :delay ]
@@ -38,7 +38,7 @@ def rate(options = {})
3838# rate of change.
3939#
4040# rates {{ :time => Time.now.to_i, :today => Date.today.to_time.to_i }}
41- # # time: 1243457162 (0.997/sec)
41+ # # time: 1243457162 (0.997/sec)
4242# # today: 1243396800 (0.000/sec)
4343def rates ( options = { } )
4444 clear = `clear`
@@ -58,8 +58,8 @@ def rates(options = {})
5858 value_delta = values . last . first [ key ] - values . first . first [ key ]
5959 rate = ( value_delta . to_f / time_delta )
6060 rate = 0 unless rate . finite?
61- last_value = values . last . first [ key ]
62- time_to_zero =
61+ last_value = values . last . first [ key ]
62+ time_to_zero =
6363 if rate != 0 && last_value != 0 && ( rate . abs / rate ) != ( last_value . abs / last_value )
6464 "%.3f hours" % ( -last_value . to_f / rate / 60 / 60 )
6565 end
0 commit comments