Class: GeneValidator::Pair
- Inherits:
-
Struct
- Object
- Struct
- GeneValidator::Pair
- Includes:
- Comparable
- Defined in:
- lib/genevalidator/clusterization.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
Overload ‘*’ operator This will modify the current object.
-
#+(other) ⇒ Object
Overload ‘+’ operator This will modify the current object.
-
#-(other) ⇒ Object
Overload ‘-’ operator Returns the euclidian distane between two pairs.
-
#/(other) ⇒ Object
Overload ‘/’ operator This will modify the current object.
-
#==(other) ⇒ Object
Overload quality operator Returns true if the pairs are equal, false otherwise.
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
- #print ⇒ Object
Instance Attribute Details
#x ⇒ Object
Returns the value of attribute x
3 4 5 |
# File 'lib/genevalidator/clusterization.rb', line 3 def x @x end |
#y ⇒ Object
Returns the value of attribute y
3 4 5 |
# File 'lib/genevalidator/clusterization.rb', line 3 def y @y end |
Instance Method Details
#*(other) ⇒ Object
Overload ‘*’ operator This will modify the current object
30 31 32 33 |
# File 'lib/genevalidator/clusterization.rb', line 30 def *(other) self.x *= other self.y *= other end |
#+(other) ⇒ Object
Overload ‘+’ operator This will modify the current object
22 23 24 25 |
# File 'lib/genevalidator/clusterization.rb', line 22 def +(other) self.x += other.x self.y += other.y end |
#-(other) ⇒ Object
Overload ‘-’ operator Returns the euclidian distane between two pairs
9 10 11 12 13 |
# File 'lib/genevalidator/clusterization.rb', line 9 def -(other) xx = other.x yy = other.y Math.sqrt((x - xx) * (x - xx) + (y - yy) * (y - yy)) end |
#/(other) ⇒ Object
Overload ‘/’ operator This will modify the current object
38 39 40 41 |
# File 'lib/genevalidator/clusterization.rb', line 38 def /(other) self.x /= other.to_f self.y /= other.to_f end |
#==(other) ⇒ Object
Overload quality operator Returns true if the pairs are equal, false otherwise
46 47 48 |
# File 'lib/genevalidator/clusterization.rb', line 46 def ==(other) other.x == x && other.y == y ? true : false end |
#eql?(other) ⇒ Boolean
50 51 52 |
# File 'lib/genevalidator/clusterization.rb', line 50 def eql?(other) self == other end |
#hash ⇒ Object
54 55 56 |
# File 'lib/genevalidator/clusterization.rb', line 54 def hash [self.x, self.y].hash end |
#print ⇒ Object
15 16 17 |
# File 'lib/genevalidator/clusterization.rb', line 15 def print warn "Cluster: #{x} #{y}" end |