Class: DrLight::ScientificNumber::Normalizer Private

Inherits:
Object
  • Object
show all
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

Author:

  • darthjee

Instance Attribute Summary collapse

Instance Method Summary collapse

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.

Parameters:

  • value (Numeric)

    number to be normalized

  • deviance (Numeric)

    deviance of number



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

#devianceInteger (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

Returns:

  • (Integer)


43
44
45
# File 'lib/dr_light/scientific_number/normalizer.rb', line 43

def deviance
  @deviance
end

#exponentialNumeric (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

Returns:

  • (Numeric)


11
12
13
# File 'lib/dr_light/scientific_number/normalizer.rb', line 11

def exponential
  @exponential
end

#significantNumeric (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

Returns:

  • (Numeric)


23
24
25
# File 'lib/dr_light/scientific_number/normalizer.rb', line 23

def significant
  @significant
end

#valueNumeric (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

Returns:

  • (Numeric)


33
34
35
# File 'lib/dr_light/scientific_number/normalizer.rb', line 33

def value
  @value
end