Capture stdout for a bloc and write to file
Easy method to capture something you make in IRB for later analysis.
by andreich 2 years, 2 months ago and tagged with: ruby stdout
1 2 3 4 5 6 7 |
def capture(file_name = "output.stdout.txt", &block) original_stdout = STDOUT.dup STDOUT.reopen(File.open(file_name, "w+")) block.call STDOUT.reopen(original_stdout) end |

Currently 0 comments