Class: Plurimath::Formatter::Numbers::NotationRenderer
- Inherits:
-
Object
- Object
- Plurimath::Formatter::Numbers::NotationRenderer
- Defined in:
- lib/plurimath/formatter/numbers/notation_renderer.rb
Overview
Builds e/scientific/engineering notation while delegating coefficient localization back through the structured renderer.
Constant Summary collapse
- SUPPORTED_NOTATIONS =
%i[e scientific engineering].freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options) ⇒ NotationRenderer
constructor
A new instance of NotationRenderer.
- #render(source, notation) ⇒ Object
Constructor Details
#initialize(options) ⇒ NotationRenderer
Returns a new instance of NotationRenderer.
11 12 13 14 15 |
# File 'lib/plurimath/formatter/numbers/notation_renderer.rb', line 11 def initialize() @options = @precision = (@options.precision || 0).to_i @exponent_sign_renderer = SignRenderer.new(@options.exponent_sign) end |
Class Method Details
.supported?(notation) ⇒ Boolean
28 29 30 |
# File 'lib/plurimath/formatter/numbers/notation_renderer.rb', line 28 def self.supported?(notation) SUPPORTED_NOTATIONS.include?(notation&.to_sym) end |
Instance Method Details
#render(source, notation) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/plurimath/formatter/numbers/notation_renderer.rb', line 17 def render(source, notation) case notation.to_sym when :e render_e(source) when :scientific render_scientific(source) when :engineering render_engineering(source) end end |