Module: Wrap

Extended by:
Wrap
Included in:
Wrap
Defined in:
lib/dpl/helper/wrap.rb

Instance Method Summary collapse

Instance Method Details

#wrap(str, width = 80) ⇒ Object



4
5
6
7
8
# File 'lib/dpl/helper/wrap.rb', line 4

def wrap(str, width = 80)
  str.lines.map do |line|
    line.size > width ? line.gsub(/(.{1,#{width}})(\s+|$)/, "\\1\n").strip : line
  end.join("\n")
end