Class: Rectangle
- Inherits:
-
Object
- Object
- Rectangle
- Defined in:
- app/models/rectangle.rb
Overview
This class describes a rectangle.
Direct Known Subclasses
Instance Attribute Summary (collapse)
-
- (Object) x1
Returns the value of attribute x1.
-
- (Object) x2
Returns the value of attribute x2.
-
- (Object) y1
Returns the value of attribute y1.
-
- (Object) y2
Returns the value of attribute y2.
Instance Method Summary (collapse)
-
- (Integer) x_center
Return center coordinate of x.
-
- (Integer) y_center
Return center coordinate of y.
Instance Attribute Details
- (Object) x1
Returns the value of attribute x1
3 4 5 |
# File 'app/models/rectangle.rb', line 3 def x1 @x1 end |
- (Object) x2
Returns the value of attribute x2
3 4 5 |
# File 'app/models/rectangle.rb', line 3 def x2 @x2 end |
- (Object) y1
Returns the value of attribute y1
3 4 5 |
# File 'app/models/rectangle.rb', line 3 def y1 @y1 end |
- (Object) y2
Returns the value of attribute y2
3 4 5 |
# File 'app/models/rectangle.rb', line 3 def y2 @y2 end |
Instance Method Details
- (Integer) x_center
Return center coordinate of x.
7 8 9 |
# File 'app/models/rectangle.rb', line 7 def x_center (@x1 + (@x2 - @x1) / 2).round end |
- (Integer) y_center
Return center coordinate of y.
13 14 15 |
# File 'app/models/rectangle.rb', line 13 def y_center (@y1 + (@y2 - @y1) / 2).round end |