Sha256: 714deb18a4ac91f7a72f75b25c4dfa22784116ab0b6d62bae1c4297de4a8a2da

Contents?: true

Size: 508 Bytes

Versions: 25

Compression:

Stored size: 508 Bytes

Contents

# encoding: UTF-8

# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0

module TwitterCldr
  module Formatters
    class AbbreviatedNumberFormatter < NumberFormatter

      def truncate_number(number, decimal_digits)
        if TwitterCldr::DataReaders::NumberDataReader.within_abbreviation_range?(number)
          factor = [0, number.to_i.abs.to_s.length - decimal_digits].max
          number / (10.0 ** factor)
        else
          number
        end
      end

    end
  end
end

Version data entries

25 entries across 25 versions & 3 rubygems

Version Path
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/twitter_cldr-4.4.5/lib/twitter_cldr/formatters/numbers/abbreviated/abbreviated_number_formatter.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/twitter_cldr-4.4.5/lib/twitter_cldr/formatters/numbers/abbreviated/abbreviated_number_formatter.rb
twitter_cldr-4.4.5 lib/twitter_cldr/formatters/numbers/abbreviated/abbreviated_number_formatter.rb
twitter_cldr-4.4.4 lib/twitter_cldr/formatters/numbers/abbreviated/abbreviated_number_formatter.rb
twitter_cldr-4.4.3 lib/twitter_cldr/formatters/numbers/abbreviated/abbreviated_number_formatter.rb
twitter_cldr-4.4.2 lib/twitter_cldr/formatters/numbers/abbreviated/abbreviated_number_formatter.rb
twitter_cldr-4.4.1 lib/twitter_cldr/formatters/numbers/abbreviated/abbreviated_number_formatter.rb
twitter_cldr-4.4.0 lib/twitter_cldr/formatters/numbers/abbreviated/abbreviated_number_formatter.rb
twitter_cldr-4.3.1 lib/twitter_cldr/formatters/numbers/abbreviated/abbreviated_number_formatter.rb
twitter_cldr-4.3.0 lib/twitter_cldr/formatters/numbers/abbreviated/abbreviated_number_formatter.rb
twitter_cldr-4.2.0 lib/twitter_cldr/formatters/numbers/abbreviated/abbreviated_number_formatter.rb
twitter_cldr-4.1.0 lib/twitter_cldr/formatters/numbers/abbreviated/abbreviated_number_formatter.rb
twitter_cldr-4.0.0 lib/twitter_cldr/formatters/numbers/abbreviated/abbreviated_number_formatter.rb
twitter_cldr-3.6.0 lib/twitter_cldr/formatters/numbers/abbreviated/abbreviated_number_formatter.rb
twitter_cldr-3.5.0 lib/twitter_cldr/formatters/numbers/abbreviated/abbreviated_number_formatter.rb
twitter_cldr-3.4.0 lib/twitter_cldr/formatters/numbers/abbreviated/abbreviated_number_formatter.rb
twitter_cldr-3.3.0 lib/twitter_cldr/formatters/numbers/abbreviated/abbreviated_number_formatter.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/twitter_cldr-3.2.1/lib/twitter_cldr/formatters/numbers/abbreviated/abbreviated_number_formatter.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/twitter_cldr-3.2.1/lib/twitter_cldr/formatters/numbers/abbreviated/abbreviated_number_formatter.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/twitter_cldr-3.1.2/lib/twitter_cldr/formatters/numbers/abbreviated/abbreviated_number_formatter.rb