Class: DrLight::ScientificNumber::Formatter Private
- Inherits:
-
Object
- Object
- DrLight::ScientificNumber::Formatter
- 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
Instance Method Summary collapse
-
#format_string ⇒ String
private
Returns the string of the format expected.
-
#initialize(normalizer) ⇒ Formatter
constructor
private
A new instance of Formatter.
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.
13 14 15 |
# File 'lib/dr_light/scientific_number/formatter.rb', line 13 def initialize(normalizer) @normalizer = normalizer end |
Instance Method Details
#format_string ⇒ String
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
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 |