Return to Snippet

Revision: 1352
at September 27, 2006 13:47 by gdonald


Updated Code
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

Revision: 1351
at September 27, 2006 13:47 by gdonald


Initial Code
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

Initial URL


Initial Description


Initial Title
Rails breakup long lines

Initial Tags


Initial Language
Ruby