class Imatcher::Rectangle
Attributes
bot[RW]
left[RW]
right[RW]
top[RW]
Public Class Methods
new(l, t, r, b)
click to toggle source
# File lib/imatcher/rectangle.rb, line 5 def initialize(l, t, r, b) @left = l @top = t @right = r @bot = b end
Public Instance Methods
area()
click to toggle source
# File lib/imatcher/rectangle.rb, line 12 def area (right - left + 1) * (bot - top + 1) end
bounds()
click to toggle source
# File lib/imatcher/rectangle.rb, line 23 def bounds [left, top, right, bot] end
contains?(rect)
click to toggle source
# File lib/imatcher/rectangle.rb, line 16 def contains?(rect) (left <= rect.left) && (right >= rect.right) && (top <= rect.top) && (bot >= rect.bot) end
contains_point?(x, y)
click to toggle source
# File lib/imatcher/rectangle.rb, line 27 def contains_point?(x, y) x.between?(left, right) && y.between?(top, bot) end