Class: Plurimath::Formatter::Numbers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/plurimath/formatter/numbers/base.rb

Direct Known Subclasses

Fraction, Integer

Instance Method Summary collapse

Instance Method Details

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



7
8
9
10
11
12
13
14
15
16
# File 'lib/plurimath/formatter/numbers/base.rb', line 7

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