method
wrap
ruby latest stable - Class:
RI::TextFormatter
wrap(txt, prefix=@indent, linelen=@width)public
No documentation available.
# File lib/rdoc/ri/ri_formatter.rb, line 28
def wrap(txt, prefix=@indent, linelen=@width)
return unless txt && !txt.empty?
work = conv_markup(txt)
textLen = linelen - prefix.length
patt = Regexp.new("^(.{0,#{textLen}})[ \n]")
next_prefix = prefix.tr("^ ", " ")
res = []
while work.length > textLen
if work =~ patt
res << $1
work.slice!(0, $&.length)
else
res << work.slice!(0, textLen)
end
end
res << work if work.length.nonzero?
puts(prefix + res.join("\n" + next_prefix))
end