class Rectangle

Attributes

height[R]
width[R]
x[R]
y[R]

Public Class Methods

new(x=0.0, y=0.0, w=0.0, h=0.0) click to toggle source
# File lib/rgw/types.rb, line 82
def initialize x=0.0, y=0.0, w=0.0, h=0.0
    @x = x
    @y = y
    @width = w
    @height = h
end

Public Instance Methods

grow!(val) click to toggle source
# File lib/rgw/types.rb, line 121
def grow!(val)
    @x -= val
    @y -= val
    @width += (val * 2.0)
    @height += (val * 2.0)
end
height=(h) click to toggle source
# File lib/rgw/types.rb, line 109
def height=(h)
    raise ArgumentError, 'invallid type for height' unless h.is_a? Numeric
    raise ArgumentError, 'height has to be >= 0' unless h >= 0.0
    @height = h.to_f
end
in(x, y) click to toggle source
# File lib/rgw/types.rb, line 116
def in x, y
    x >= @x and x <= @x + @width and y >= @y and y <= @y + @height
end
width=(w) click to toggle source
# File lib/rgw/types.rb, line 102
def width=(w)
    raise ArgumentError, 'invallid type for width' unless w.is_a? Numeric
    raise ArgumentError, 'width has to be >= 0' unless w >= 0.0
    @width = w.to_f
end
x=(x) click to toggle source
# File lib/rgw/types.rb, line 90
def x=(x)
    raise ArgumentError, 'invallid type for pos x' unless x.is_a? Numeric
    @x = x.to_f
end
y=(y) click to toggle source
# File lib/rgw/types.rb, line 96
def y=(y)
    raise ArgumentError, 'invallid type for pos y' unless y.is_a? Numeric
    @y = y.to_f
end