require 'echo'
echo("foo msg") > "foofile"
echo("foo msg") >> "foofile"
-
-
Save tenderlove/220300 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 echo msg | |
Struct.new(:msg) { | |
def method_missing sym, fname | |
open(fname, sym == :> ? 'w' : 'a+') { |f| f.puts msg } || msg | |
end | |
}.new msg | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment