Sha256: 1b12b6bde2ed28a3bc5db49ee88675d3afb4031387954f1721336f7b519d7258

Contents?: true

Size: 558 Bytes

Versions: 5

Compression:

Stored size: 558 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 = orientation == :left ? 0 : -length

          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

5 entries across 5 versions & 1 rubygems

Version Path
twitter_cldr-1.9.1 lib/twitter_cldr/formatters/numbers/helpers/base.rb
twitter_cldr-1.9.0 lib/twitter_cldr/formatters/numbers/helpers/base.rb
twitter_cldr-1.8.1 lib/twitter_cldr/formatters/numbers/helpers/base.rb
twitter_cldr-1.8.0 lib/twitter_cldr/formatters/numbers/helpers/base.rb
twitter_cldr-1.7.0 lib/twitter_cldr/formatters/numbers/helpers/base.rb