Class: DrLight::ScientificNumber::Normalizer Private
- Inherits:
-
Object
- Object
- DrLight::ScientificNumber::Normalizer
- Defined in:
- lib/dr_light/scientific_number/normalizer.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 normalizing the scientific number
Instance Attribute Summary collapse
-
#deviance ⇒ Integer
readonly
private
Deviance representation.
-
#exponential ⇒ Numeric
readonly
private
Exponential factor of number.
-
#significant ⇒ Numeric
readonly
private
Significant decimals to be shown from the value.
-
#value ⇒ Numeric
readonly
private
The value after normalization.
Instance Method Summary collapse
-
#initialize(value:, deviance:) ⇒ Normalizer
constructor
private
A new instance of Normalizer.
Constructor Details
#initialize(value:, deviance:) ⇒ Normalizer
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 Normalizer.
55 56 57 58 59 60 61 |
# File 'lib/dr_light/scientific_number/normalizer.rb', line 55 def initialize(value:, deviance:) @value = value @deviance = deviance @significant = 1 normalize_value normalize_deviance end |
Instance Attribute Details
#deviance ⇒ Integer (readonly)
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.
Deviance representation
Deviance will always be a number between 10 and and 100
43 44 45 |
# File 'lib/dr_light/scientific_number/normalizer.rb', line 43 def deviance @deviance end |
#exponential ⇒ Numeric (readonly)
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.
Exponential factor of number
Any number can be represented by the exponencial format.
ex: 12.4
can be represented 1.24e1
11 12 13 |
# File 'lib/dr_light/scientific_number/normalizer.rb', line 11 def exponential @exponential end |
#significant ⇒ Numeric (readonly)
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.
Significant decimals to be shown from the value
The smaller the #deviance, more significant digits need to be shown
23 24 25 |
# File 'lib/dr_light/scientific_number/normalizer.rb', line 23 def significant @significant end |
#value ⇒ Numeric (readonly)
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.
The value after normalization
Value will be returned always being a value between -10 and 10
33 34 35 |
# File 'lib/dr_light/scientific_number/normalizer.rb', line 33 def value @value end |