Class: DrLight::ScientificNumber::DevianceDistance Private
- Inherits:
-
Object
- Object
- DrLight::ScientificNumber::DevianceDistance
- Defined in:
- lib/dr_light/scientific_number/deviance_distance.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Class Responsible for calculating distance between 2 numbers in number of deviances
The combined deviance of numbers n1(d1), n2(d2) is d = sqrt(d1 ** 2 + d2 ** 2)
Instance Method Summary collapse
-
#initialize(number, other) ⇒ DevianceDistance
constructor
private
A new instance of DevianceDistance.
-
#to_f ⇒ Float
private
Calculates the distance of numbers in deviances.
Constructor Details
#initialize(number, other) ⇒ DevianceDistance
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of DevianceDistance.
37 38 39 40 41 42 43 44 45 |
# File 'lib/dr_light/scientific_number/deviance_distance.rb', line 37 def initialize(number, other) @number = number @other = if other.is_a?(ScientificNumber) other else ScientificNumber.new(other) end end |
Instance Method Details
#to_f ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Calculates the distance of numbers in deviances
50 51 52 53 54 |
# File 'lib/dr_light/scientific_number/deviance_distance.rb', line 50 def to_f return 0 if difference.zero? difference / deviance end |