Created
May 16, 2017 18:38
-
-
Save KrzaQ/ccb722105a478d2ef94a868c152509a7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def filter_line(line) | |
| line.gsub!(/\x0f/, '') | |
| line.gsub!(/\x03\d?\d?/, '') | |
| line.gsub!(/\x02/, '') | |
| line | |
| end | |
| def filter_file(name) | |
| File.read(name).each_line.map{ |line| filter_line line } | |
| end | |
| def work_on_file(name) | |
| File.write('out.log', filter_file(name).join("\n")) | |
| end | |
| def use_stdin | |
| ARGF.each_line do |line| | |
| print filter_line line | |
| end | |
| end | |
| if(ARGV.size == 1) | |
| work_on_file ARGV[0] | |
| else | |
| use_stdin | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment