# What chomp removes, line ending by line ending, and the other tools for the job.
def show(code, value) = puts("  #{code.ljust(40)} #{value.inspect}")

puts "chomp with no argument:"
["unix\n", "windows\r\n", "old mac\r", "no ending", "blank line after\n\n"].each do |line|
  show("#{line.inspect}.chomp", line.chomp)
end
puts
puts "With an argument:"
show('"blank line after\n\n".chomp("")', "blank line after\n\n".chomp(""))
show('"windows\r\n".chomp("\n")', "windows\r\n".chomp("\n"))
show('"windows\r\n".chomp("\r")', "windows\r\n".chomp("\r"))
puts
puts "Splitting text with mixed endings:"
text = "one\r\ntwo\rthree\nfour"
show("text.lines", text.lines)
show("text.each_line(chomp: true).to_a", text.each_line(chomp: true).to_a)
show("text.split(/\\R/)", text.split(/\R/))
show("text.encode(universal_newline: true)", text.encode(universal_newline: true))
