class Numerals::Format::LatexNotation
Public Instance Methods
assemble(output, text_parts)
click to toggle source
# File lib/numerals/format/notations/latex.rb, line 7 def assemble(output, text_parts) # 1.23\overline{456}\times10^{9} # TODO: padding if text_parts.special? output << text_parts.special else output << text_parts.sign if format.symbols.base_prefix output << format.symbols.base_prefix end output << text_parts.integer # or decide here if empty integer part is shown as 0? if text_parts.show_point?(format) output << format.symbols.point end output << text_parts.fractional if text_parts.repeat? output << "\\overline{#{text_parts.repeat}}" end if format.symbols.base_suffix || format.base != 10 if format.symbols.base_prefix output << format.symbols.base_suffix else # show base suffix as a subscript subscript = format.symbols.base_suffix || base.to_s output << "_{#{subscript}}" end end if text_parts.exponent_value != 0 || format.mode.mode == :scientific output << "\\times" output << text_parts.exponent_base output << "^" output << "{#{text_parts.exponent}}" end end end
Private Instance Methods
escape(text)
click to toggle source
# File lib/numerals/format/notations/latex.rb, line 45 def escape(text) text.gsub('\\', '\\\\') end
unescape(text)
click to toggle source
# File lib/numerals/format/notations/latex.rb, line 49 def unescape(text) text.gsub('\\\\', '\\') end