Class: Polynomials::Point
- Inherits:
-
Object
- Object
- Polynomials::Point
show all
- Includes:
- Comparable
- Defined in:
- lib/polynomials/point.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(x, y) ⇒ Point
15
16
17
|
# File 'lib/polynomials/point.rb', line 15
def initialize(x,y)
@x,@y = x,y
end
|
Instance Attribute Details
#x ⇒ Object
Also known as:
to_f
Returns the value of attribute x.
4
5
6
|
# File 'lib/polynomials/point.rb', line 4
def x
@x
end
|
#y ⇒ Object
Returns the value of attribute y.
4
5
6
|
# File 'lib/polynomials/point.rb', line 4
def y
@y
end
|
Instance Method Details
#<=>(other) ⇒ Object
23
24
25
26
27
28
29
30
31
|
# File 'lib/polynomials/point.rb', line 23
def <=>(other)
if self.x < other.x
-1
elsif self.x > other.x
1
elsif self.x == other.x && self.y == other.y
0
end
end
|
#eql?(other) ⇒ Boolean
33
34
35
36
37
|
# File 'lib/polynomials/point.rb', line 33
def eql?(other)
self.x == other.x &&
self.y == other.y &&
other.class == self.class
end
|
#to_s ⇒ Object
19
20
21
|
# File 'lib/polynomials/point.rb', line 19
def to_s
"(#{self.x.inspect},#{self.y.inspect})"
end
|