Skip to content

Instantly share code, notes, and snippets.

@metzenseifner
Created June 30, 2017 06:13
Show Gist options
  • Save metzenseifner/0474aca730cb19ec84c16df7c2505fdc to your computer and use it in GitHub Desktop.
Save metzenseifner/0474aca730cb19ec84c16df7c2505fdc to your computer and use it in GitHub Desktop.
Ruby Get Line Endings
#!/usr/bin/env ruby
ARGF.each do |line|
if $. == 1
if line =~ /\r\n$/
puts "CRLF"
elsif line =~/\n$/
puts "LF"
elsif line =~ /\r$/
puts "CR"
else
puts "Line endings not detected."
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment