This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def split string, length | |
split = Array.new | |
if string.length > length #if the string needs to be split | |
string_words = string.split(" ") | |
line = "" | |
string_words.each do |x| | |
if x.length > length #if the word needs to be split | |
#add the start of the word onto the first line (even if it has already started) | |
while line.length < length | |
line += x[0] |