class Accumulators::MinMax

Attributes

max[R]
min[R]

Public Instance Methods

add(rhs) click to toggle source
# File lib/accumulators/minmax.rb, line 6
def add(rhs)
  if rhs.is_a? Numeric
    @min = [@min, rhs].min rescue rhs
    @max = [@max, rhs].max rescue rhs
  elsif rhs.is_a? self.class
    @min = [@min, rhs.min].min rescue rhs.min
    @max = [@max, rhs.max].max rescue rhs.max
  else
    raise ArgumentError.new("You may not add #{rhs.class} to #{self.class}")
  end
end