I have file called regional.txt and it has data as below :
shell.SetMyFile "Ranger"
shell.SetMyErrorFile "Discovery"
shell.SetMyFileEnabled 1
shell.SetMyLogFileEnabled 1
Now I am reading this file using ruby and trying to filter the text from "shell.SetMyFile" and "shell.SetMyErrorFile" as Ranger and Discovery:
File.readlines("regional.txt").each do |line|
value1 = line.split(" ")[1] if line.include?("shell.SetMyFile")
value2 = line.split(" ")[1] if line.include?("shell.SetMyErrorFile ")
puts value1, value2
end
My result is 1 ,1 rather than Ranger and Discovery. This is because include? method considering the "shell.SetMyFileEnabled" and "shell.SetMyLogFileEnabled". How can I filter it to the desired result ?