Class: DrLight::ScientificNumber::Formatter Private

Inherits:
Object
  • Object
show all
Defined in:
lib/dr_light/scientific_number/formatter.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 formatting the values of DrLight::ScientificNumber

Author:

  • darthjee

Instance Method Summary collapse

Constructor Details

#initialize(normalizer) ⇒ Formatter

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 Formatter.

Parameters:

  • normalizer (Normalizer)

    normalizer with number and deviance information



13
14
15
# File 'lib/dr_light/scientific_number/formatter.rb', line 13

def initialize(normalizer)
  @normalizer = normalizer
end

Instance Method Details

#format_stringString

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 the string of the format expected

Returns:

  • (String)

See Also:



22
23
24
25
26
27
# File 'lib/dr_light/scientific_number/formatter.rb', line 22

def format_string
  ["%<value>.#{normalizer.significant}f"].tap do |values|
    values << '(%<deviance>d)' if deviance?
    values << 'e%<exponential>d' if exponential?
  end.join
end