Sha256: 3c742597e4d7d600afb8f6e9ab199f594741b3d7c5599e0d8796964e225a1f0e
Contents?: true
Size: 738 Bytes
Versions: 7
Compression:
Stored size: 738 Bytes
Contents
# encoding: UTF-8 # Copyright 2012 Twitter, Inc # http://www.apache.org/licenses/LICENSE-2.0 module TwitterCldr module Formatters class AbbreviatedNumberFormatter < NumberFormatter FORMAT_REGEX = /^0+$/ protected def truncate_number(number, integer_format) if TwitterCldr::DataReaders::NumberDataReader.within_abbreviation_range?(number) if integer_format.format =~ FORMAT_REGEX factor = [0, number.to_i.to_s.length - integer_format.format.length].max number / (10.0 ** factor) else raise ArgumentError.new("unexpected format string #{integer_format.inspect}") end else number end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems