[Noisebridge-discuss] Another try at a Ruby group...

Sai Emrys noisebridge at saizai.com
Sun Jul 26 07:39:28 UTC 2009


On Sun, Jul 26, 2009 at 12:10 AM, Jonathan Lassoff<jof at thejof.com> wrote:
>        ARGV.each do |arg|
>                if arg == "-" then
>                        $stdout.write($stdin.read)
>                else
>                        $stdout.write open(arg).read
>                end
>        end

Ruby has a special global $< that'd simplify the above.

Quoting the doc book:
$<  (returns a read-only Object)
An object that provides access to the concatenation of the contents of
all the files given as command-line arguments or $stdin (in the case
where there are no arguments). $< supports methods similar to a File
object: binmode, close, closed?, each, each_byte, each_line, eof,
eof?, file, filename, fileno, getc, gets, lineno, lineno=, path, pos,
pos=, read, readchar, readline, readlines, rewind, seek, skip, tell,
to_a, to_i, to_io, to_s, along with the methods in Enumerable. The
method file returns a File object for the file currently being rad.
This may change as $< reads through files on the command line.

- Sai



More information about the Noisebridge-discuss mailing list