Class: Fuzzyrb::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.



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

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

Instance Attribute Details

#xObject

Returns the value of attribute x.



23
24
25
# File 'lib/point.rb', line 23

def x
  @x
end

#yObject

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

Returns:

  • (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