W
WuyaSea Operator
doing formating, i need to break a long line of words to roughly 80
chars per line, below is what I got
def break_line(text)
return text if text.size < 80
i = text.index(' ', 79)
text[0..i] + "\n" + break_line(text[i+1..-1])
end
can it be any shorter, more rubyish? Thank you.
operator
www.wuyaSea.com
chars per line, below is what I got
def break_line(text)
return text if text.size < 80
i = text.index(' ', 79)
text[0..i] + "\n" + break_line(text[i+1..-1])
end
can it be any shorter, more rubyish? Thank you.
operator
www.wuyaSea.com