/ Published in: Ruby
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
def break_up_long_line(str, max) counter = 0 new_text = '' for i in 0...str.length if str[i,1] =~ /\n/ counter = 0 else counter = counter + 1 end new_text << str[i,1] if counter >= max && str[i,1] =~ /\s/ new_text << "\n" counter = 0 end end new_text end