Class: Point
- Inherits:
-
Object
- Object
- Point
- Defined in:
- lib/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
-
#initialize(x, y) ⇒ Point
constructor
A new instance of Point.
- #initialize_copy(orig) ⇒ Object
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
#x ⇒ Object
Returns the value of attribute x.
13 14 15 |
# File 'lib/point.rb', line 13 def x @x end |
#y ⇒ Object
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 |