Skip to content

Instantly share code, notes, and snippets.

@dtaniwaki
Created March 13, 2014 09:32
Show Gist options
  • Save dtaniwaki/9525119 to your computer and use it in GitHub Desktop.
Save dtaniwaki/9525119 to your computer and use it in GitHub Desktop.
class MultiIO
def initialize(*targets)
@targets = targets.map{ |t|t.is_a?(String) ? open(t, 'a') : t }
end
def write(*args)
@targets.each{ |t| t.write(*args) }
end
def close
@targets.each(&:close)
end
def puts(*args)
@targets.each{ |t| t.puts(*args) }
end
def tty?
@targets.all?(&:tty?)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment