Class: Dotter::Point
- Inherits:
-
Object
- Object
- Dotter::Point
- Defined in:
- lib/dotter/point.rb
Instance Attribute Summary collapse
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
- #+(other) ⇒ Object
- #-(other) ⇒ Object
- #==(other) ⇒ Object
-
#initialize(x, y) ⇒ Point
constructor
A new instance of Point.
Constructor Details
#initialize(x, y) ⇒ Point
Returns a new instance of Point.
4 5 6 |
# File 'lib/dotter/point.rb', line 4 def initialize(x, y) @x, @y = x, y end |
Instance Attribute Details
#x ⇒ Object
Returns the value of attribute x.
2 3 4 |
# File 'lib/dotter/point.rb', line 2 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
2 3 4 |
# File 'lib/dotter/point.rb', line 2 def y @y end |
Instance Method Details
#+(other) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/dotter/point.rb', line 19 def +(other) point = self.dup point.x += other.x point.y += other.y point end |
#-(other) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/dotter/point.rb', line 12 def -(other) point = self.dup point.x -= other.x point.y -= other.y point end |
#==(other) ⇒ Object
8 9 10 |
# File 'lib/dotter/point.rb', line 8 def ==(other) x == other.x && y == other.y end |