Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Forked from bmizerany/README.md
Created October 28, 2009 06:42
Show Gist options
  • Save tenderlove/220300 to your computer and use it in GitHub Desktop.
Save tenderlove/220300 to your computer and use it in GitHub Desktop.

echo

Usage

require 'echo'

echo("foo msg") > "foofile"
echo("foo msg") >> "foofile"
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