Class: AGL::Rectangle
- Inherits:
-
Object
- Object
- AGL::Rectangle
- Defined in:
- lib/minigl/global.rb
Instance Attribute Summary collapse
-
#h ⇒ Object
Returns the value of attribute h.
-
#w ⇒ Object
Returns the value of attribute w.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
-
#initialize(x, y, w, h) ⇒ Rectangle
constructor
A new instance of Rectangle.
- #intersects(r) ⇒ Object
Constructor Details
#initialize(x, y, w, h) ⇒ Rectangle
Returns a new instance of Rectangle.
9 10 11 |
# File 'lib/minigl/global.rb', line 9 def initialize x, y, w, h @x = x; @y = y; @w = w; @h = h end |
Instance Attribute Details
#h ⇒ Object
Returns the value of attribute h.
7 8 9 |
# File 'lib/minigl/global.rb', line 7 def h @h end |
#w ⇒ Object
Returns the value of attribute w.
7 8 9 |
# File 'lib/minigl/global.rb', line 7 def w @w end |
#x ⇒ Object
Returns the value of attribute x.
7 8 9 |
# File 'lib/minigl/global.rb', line 7 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
7 8 9 |
# File 'lib/minigl/global.rb', line 7 def y @y end |
Instance Method Details
#intersects(r) ⇒ Object
13 14 15 |
# File 'lib/minigl/global.rb', line 13 def intersects r @x < r.x + r.w && @x + @w > r.x && @y < r.y + r.h && @y + @h > r.y end |