Class: TwitterCldr::Formatters::Numbers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/twitter_cldr/formatters/numbers/helpers/base.rb

Direct Known Subclasses

Fraction, Integer

Instance Method Summary collapse

Instance Method Details

#interpolate(string, value, orientation = :right) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/twitter_cldr/formatters/numbers/helpers/base.rb', line 10

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