Sha256: 993d829e1da63eb796d5116d8c9595e65fd06fac16a548a7e3deddf73b7db335

Contents?: true

Size: 583 Bytes

Versions: 10

Compression:

Stored size: 583 Bytes

Contents

# encoding: UTF-8

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

module TwitterCldr
  module Formatters
    module Numbers
      class Base
        def interpolate(string, value, orientation = :right)
          value  = value.to_s
          length = value.length
          start, pad = orientation == :left ? [0, :rjust] : [-length, :ljust]

          string = string.dup
          string = string.ljust(length, '#') if string.length < length
          string[start, length] = value
          string.gsub('#', '')
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
twitter_cldr-1.6.2 lib/twitter_cldr/formatters/numbers/helpers/base.rb
twitter_cldr-1.6.1 lib/twitter_cldr/formatters/numbers/helpers/base.rb
twitter_cldr-1.6.0 lib/twitter_cldr/formatters/numbers/helpers/base.rb
twitter_cldr-1.5.0 lib/twitter_cldr/formatters/numbers/helpers/base.rb
twitter_cldr-1.4.1 lib/twitter_cldr/formatters/numbers/helpers/base.rb
twitter_cldr-1.4.0 lib/twitter_cldr/formatters/numbers/helpers/base.rb
twitter_cldr-1.3.6 lib/twitter_cldr/formatters/numbers/helpers/base.rb
twitter_cldr-1.3.0 lib/twitter_cldr/formatters/numbers/helpers/base.rb
twitter_cldr-1.2.0 lib/twitter_cldr/formatters/numbers/helpers/base.rb
twitter_cldr-1.1.0 lib/formatters/numbers/helpers/base.rb