Class: Point
- Inherits:
-
Object
- Object
- Point
- Defined in:
- lib/kut/misc/point.rb
Instance Attribute Summary collapse
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Class Method Summary collapse
Instance Method Summary collapse
- #+(pt) ⇒ Object
- #-(pt) ⇒ Object
- #==(pt) ⇒ Object
-
#initialize(x = 0, y = 0) ⇒ Point
constructor
A new instance of Point.
Constructor Details
#initialize(x = 0, y = 0) ⇒ Point
Returns a new instance of Point.
5 6 7 8 |
# File 'lib/kut/misc/point.rb', line 5 def initialize(x = 0, y = 0) @x = x @y = y end |
Instance Attribute Details
#x ⇒ Object
Returns the value of attribute x.
3 4 5 |
# File 'lib/kut/misc/point.rb', line 3 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
3 4 5 |
# File 'lib/kut/misc/point.rb', line 3 def y @y end |
Class Method Details
Instance Method Details
#+(pt) ⇒ Object
14 15 16 |
# File 'lib/kut/misc/point.rb', line 14 def +(pt) return Point[@x + pt.x, @y + pt.y] end |
#-(pt) ⇒ Object
18 19 20 |
# File 'lib/kut/misc/point.rb', line 18 def -(pt) return Point[@x - pt.x, @y - pt.y] end |
#==(pt) ⇒ Object
22 23 24 |
# File 'lib/kut/misc/point.rb', line 22 def ==(pt) (pt.x == @x) && (pt.y == @y) ? true : false end |