From: Suraj Kurapati Date: 2012-03-29T06:07:38+09:00 Subject: Re: Javascript vs. Ruby - how would this look in Ruby? ------=_Part_830_13019982.1332968856411 Content-Type: multipart/alternative; boundary="----=_Part_831_18393594.1332968856411" ------=_Part_831_18393594.1332968856411 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On Saturday, March 17, 2012 5:08:24 PM UTC-7, Jan E. wrote: > > class TimeSeries > def append timestamp, value > @data << [timestamp, value] > @max_value = value unless @max_value and @max_value >= value > @min_value = value unless @min_value and @min_value <= value > @max_value = [@max_value, value].compact.max @min_value = [@min_value, value].compact.min end > end > > ------=_Part_831_18393594.1332968856411 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit On Saturday, March 17, 2012 5:08:24 PM UTC-7, Jan E. wrote:

class TimeSeries
  def append timestamp, value
    @data << [timestamp, value]
    @max_value = value unless @max_value and @max_value >= value
    @min_value = value unless @min_value and @min_value <= value

 @max_value = [@max_value, value].compact.max
 @min_value = [@min_value, value].compact.min

  end
end

------=_Part_831_18393594.1332968856411-- ------=_Part_830_13019982.1332968856411--