word_wrap(text, options = {})
Instance Public methods
Wraps the text
into lines no longer than
line_width
width. This method breaks on the first whitespace
character that does not exceed line_width
(which is 80 by
default).
1 2 3 4 5 6 7 8 9 10 11 | word_wrap( 'Once upon a time' ) # => Once upon a time word_wrap( 'Once upon a time, in a kingdom called Far Far Away, a king fell ill, and finding a successor to the throne turned out to be more trouble than anyone could have imagined...' ) # => Once upon a time, in a kingdom called Far Far Away, a king fell ill, and finding\na successor to the throne turned out to be more trouble than anyone could have\nimagined... word_wrap( 'Once upon a time' , line_width: 8 ) # => Once\nupon a\ntime word_wrap( 'Once upon a time' , line_width: 1 ) # => Once\nupon\na\ntime |
Please login to continue.