A heredoc stores multiline text that can be split and processed line by line.

Heredoc Lines

heredoc_lines.rb
prefix = 

notes = <<~TEXT
  TODO wash
  DONE fold
  TODO pack
TEXT

lines = notes.lines.map do |line|
  line.strip
end

selected = lines.select do |line|
  line.start_with?(prefix)
end

puts "prefix=#{prefix}"
puts "line_count=#{lines.length}"
selected_text = selected.join(", ")

puts "selected=#{selected_text}"
prefix = 

notes = <<~TEXT
  TODO wash
  DONE fold
  TODO pack
TEXT

lines = notes.lines.map do |line|
  line.strip
end

selected = lines.select do |line|
  line.start_with?(prefix)
end

puts "prefix=#{prefix}"
puts "line_count=#{lines.length}"
selected_text = selected.join(", ")

puts "selected=#{selected_text}"
prefix = 

notes = <<~TEXT
  TODO wash
  DONE fold
  TODO pack
TEXT

lines = notes.lines.map do |line|
  line.strip
end

selected = lines.select do |line|
  line.start_with?(prefix)
end

puts "prefix=#{prefix}"
puts "line_count=#{lines.length}"
selected_text = selected.join(", ")

puts "selected=#{selected_text}"
heredoc A heredoc creates a multiline string while keeping the text readable in source code.