Module: Chamomile::Wrap

Defined in:
lib/chamomile/styling/wrap.rb

Class Method Summary collapse

Class Method Details

.word_wrap(str, width) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/chamomile/styling/wrap.rb', line 6

def word_wrap(str, width)
  return str if width <= 0

  lines = str.split("\n", -1)
  result = []

  lines.each do |line|
    result.concat(wrap_line(line, width))
  end

  result.join("\n")
end