I'm trying to go through a file to check every line with what white space it starts. we want to use space as a start or a tab. If one line starts with space and another line with tab I want to inform the user that the white spaces are not consistent. And an example I want to print one line that starts with space and one line that starts with tab. And Im stuck at the getting the line number part. I tried file.gets to get the first white space but it isnt working for me(so I didnt include it in my code below). Help how do I print the line number.
tabs = spaces = false
file = File.read("file_name")
file.each do |line|
line =~ /^\t/ and tabs = true
line =~ /^ / and spaces = true
if spaces and tabs
puts "The white spaces at the beginning of each line are not consistent.\n"
break
end
end