Created
March 13, 2014 09:32
-
-
Save dtaniwaki/9525119 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
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