def bound(val)
    case val
    when Rectangle then
      r = val.clone
      r.size = r.size.min(size)
      r.loc = r.loc.bound(loc, loc + size - val.size)
      r
    when Point then (val-loc).bound(point, size) + loc
    else raise ArgumentError.new("wrong type: (#{val.class}) - Rectangle or Point expected")
    end
  end
def bound(val)
    case val
    when Rectangle then
      r = val.clone
      r.size = r.size.min(size)
      r.loc = r.loc.bound(loc, loc + size - val.size)
      r
    when Point then (val-loc).bound(point, size) + loc
    else raise ArgumentError.new("wrong type: (#{val.class}) - Rectangle or Point expected")
    end
  end
def bound ( val ) case val when Rectangle then r = val . clone r . size = r . size . min ( size ) r . loc = r . loc . bound ( loc , loc + size - val . size ) r when Point then ( val - loc ) . bound ( point , size ) + loc else raise ArgumentError . new ( "wrong type: (#{val.class}) - Rectangle or Point expected" ) end end
val can be a Rectangle or Point
 returns a Rectangle or Point that is within this Rectangle
 For Rectangles, the size is only changed if it has to be
val can be a Rectangle or Point returns a Rectangle or Point that is within this Rectangle For Rectangles the size is only changed if it has to be