"Ruby iterate over lines in a string"

str.each_line do |line|
  #do something with line
end

Source.

social