Class: Newral::Classifier::NodeDistance
- Inherits:
-
Object
- Object
- Newral::Classifier::NodeDistance
- Defined in:
- lib/newral/classifier/node_distance.rb
Instance Attribute Summary collapse
-
#distance ⇒ Object
readonly
Returns the value of attribute distance.
-
#node1 ⇒ Object
readonly
Returns the value of attribute node1.
-
#node2 ⇒ Object
readonly
Returns the value of attribute node2.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(node1, node2) ⇒ NodeDistance
constructor
A new instance of NodeDistance.
Constructor Details
#initialize(node1, node2) ⇒ NodeDistance
Returns a new instance of NodeDistance.
6 7 8 9 10 |
# File 'lib/newral/classifier/node_distance.rb', line 6 def initialize( node1, node2 ) @node1 = node1 @node2 = node2 @distance = Newral::Tools.euclidian_distance( node1.center, node2.center ) end |
Instance Attribute Details
#distance ⇒ Object (readonly)
Returns the value of attribute distance.
5 6 7 |
# File 'lib/newral/classifier/node_distance.rb', line 5 def distance @distance end |
#node1 ⇒ Object (readonly)
Returns the value of attribute node1.
5 6 7 |
# File 'lib/newral/classifier/node_distance.rb', line 5 def node1 @node1 end |
#node2 ⇒ Object (readonly)
Returns the value of attribute node2.
5 6 7 |
# File 'lib/newral/classifier/node_distance.rb', line 5 def node2 @node2 end |
Instance Method Details
#<=>(other) ⇒ Object
12 13 14 |
# File 'lib/newral/classifier/node_distance.rb', line 12 def <=>( other ) self.distance <=> other.distance end |