Class: Dotter::Point

Inherits:
Object
  • Object
show all
Defined in:
lib/dotter/point.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#xObject

Returns the value of attribute x.



2
3
4
# File 'lib/dotter/point.rb', line 2

def x
  @x
end

#yObject

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