Module: TextUtils

Included in:
CopyMachine
Defined in:
lib/text_utils.rb

Instance Method Summary collapse

Instance Method Details

#surround(text, pattern, length = 80) ⇒ Object



2
3
4
5
6
# File 'lib/text_utils.rb', line 2

def surround(text, pattern, length = 80)
  left = (length - text.length - 2) / 2
  right = left + (length - text.length - 2) % 2
  pattern + (' ' * left) + text + (' ' * right) + pattern
end