Skip to content

Instantly share code, notes, and snippets.

@dipnlik
Created July 1, 2012 20:47
Show Gist options
  • Save dipnlik/5c353d4bcbb564a7a8ca to your computer and use it in GitHub Desktop.
Save dipnlik/5c353d4bcbb564a7a8ca to your computer and use it in GitHub Desktop.
writing @output to a file with a custom output class
class DoubleOutputter
def initialize(filename)
@file = File.new(filename, 'w+')
end
def puts(string)
@file.puts string
$stdout.puts string
end
def close
@file.close
end
end
@output = DoubleOutputter.new('dump.txt')
@output.puts "line 1"
@output.puts "line 2"
@output.puts "line 3"
@output.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment