Class: Fuzzyrb::Point
- Inherits:
-
Object
- Object
- Fuzzyrb::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
- #eql?(other) ⇒ Boolean
-
#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.
3 4 5 6 |
# File 'lib/point.rb', line 3 def initialize(x, y) @x = x @y = y end |
Instance Attribute Details
#x ⇒ Object
Returns the value of attribute x.
23 24 25 |
# File 'lib/point.rb', line 23 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
23 24 25 |
# File 'lib/point.rb', line 23 def y @y end |
Instance Method Details
#<=>(other) ⇒ Object
8 9 10 |
# File 'lib/point.rb', line 8 def <=>(other) self.x <=> other.x end |
#eql?(other) ⇒ Boolean
12 13 14 15 16 17 |
# File 'lib/point.rb', line 12 def eql?(other) if (self.x-other.x).abs <= EPSILON and (self.y - other.y).abs <= EPSILON return true end return false end |
#initialize_copy(orig) ⇒ Object
19 20 21 22 |
# File 'lib/point.rb', line 19 def initialize_copy(orig) @x = orig.x @y = orig.y end |