Class: Rect
- Inherits:
-
Object
- Object
- Rect
- Defined in:
- lib/rect.rb
Overview
The rectangle class.
Instance Attribute Summary collapse
-
#height ⇒ Object
The rectangle’s height.
-
#width ⇒ Object
The rectangle’s width.
-
#x ⇒ Object
The X-coordinate of the rectangle’s upper left corner.
-
#y ⇒ Object
The Y-coordinate of the rectange’s upper left corner.
Instance Method Summary collapse
-
#initialize(x, y, width, height) ⇒ Rect
constructor
A new instance of Rect.
-
#set(x, y, width, height) ⇒ Object
Sets all parameters at once.
Constructor Details
#initialize(x, y, width, height) ⇒ Rect
Returns a new instance of Rect.
15 16 17 |
# File 'lib/rect.rb', line 15 def initialize(x, y, width, height) set x, y, width, height end |
Instance Attribute Details
#height ⇒ Object
The rectangle’s height.
13 14 15 |
# File 'lib/rect.rb', line 13 def height @height end |
#width ⇒ Object
The rectangle’s width.
10 11 12 |
# File 'lib/rect.rb', line 10 def width @width end |
#x ⇒ Object
The X-coordinate of the rectangle’s upper left corner.
4 5 6 |
# File 'lib/rect.rb', line 4 def x @x end |
#y ⇒ Object
The Y-coordinate of the rectange’s upper left corner.
7 8 9 |
# File 'lib/rect.rb', line 7 def y @y end |
Instance Method Details
#set(x, y, width, height) ⇒ Object
Sets all parameters at once.
20 21 22 23 24 25 |
# File 'lib/rect.rb', line 20 def set(x, y, width, height) @x = x @y = y @width = width @height = height end |