Class: Point

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y) ⇒ Point

Returns a new instance of Point.



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

def initialize(x, y)
  @x = x
  @y = y
end

Instance Attribute Details

#xObject

Returns the value of attribute x.



13
14
15
# File 'lib/point.rb', line 13

def x
  @x
end

#yObject

Returns the value of attribute y.



13
14
15
# File 'lib/point.rb', line 13

def y
  @y
end

Instance Method Details

#<=>(other) ⇒ Object



6
7
8
# File 'lib/point.rb', line 6

def <=>(other)
  self.x <=> other.x
end

#initialize_copy(orig) ⇒ Object



9
10
11
12
# File 'lib/point.rb', line 9

def initialize_copy(orig)
  @x = orig.x
  @y = orig.y
end