Sha256: 545b2005768c20c3ecd4a7a06965ddb890008f39c2969a115311a1b47c077e33
Contents?: true
Size: 1.07 KB
Versions: 7
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true module Plurimath module Formatter class NumberFormatter < TwitterCldr::Formatters::NumberFormatter def format(tokens, number, options = {}) options[:precision] ||= precision_from(number) options[:type] ||= :decimal prefix, suffix, integer_format, fraction_format = *partition_tokens(tokens) number = truncate_number(number, integer_format.format.length) int, fraction = parse_number(number, options) result = integer_format.apply(int, options) result << fraction_format.apply(fraction, options, int) if fraction number_system.transliterate( "#{prefix.to_s}#{result}#{suffix.to_s}" ) end private def partition_tokens(tokens) [ token_val_from(tokens[0]), token_val_from(tokens[2]), Numbers::Integer.new( tokens[1], data_reader.symbols ), Numbers::Fraction.new( tokens[1], data_reader.symbols ) ] end end end end
Version data entries
7 entries across 7 versions & 1 rubygems