I read about Dave Thomas Ruby one liners
Its says
# print section of file between two regular expressions, /foo/ and /bar/
$ ruby -ne '@found=true if $_ =~ /foo/; next unless @found; puts $_; exit if $_ =~ /bar/' < file.txt
May I know how i can use this is my Ruby code and not from command line?
According to ruby CLI reference,
So, just copy the code snippet to a ruby file enclosed in gets() loop
foobar.rb
And execute the file using
You can also replace IO redirect by reading the file programmatically