From: "Shot (Piotr Szotkowski)" Date: 2009-11-21T23:19:59+09:00 Subject: Re: select only taking alternating values? --ibTvN161/egqYuK8 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Brian Candler: > Incidentally, a plain gets is *not* the same as STDIN.gets, but is > more like ARGF.gets. It makes a difference when someone puts some > arguments on the command line. Use STDIN.gets to be safe. Or, better yet, use $stdin.gets =E2=80=93 IMHO in general it=E2=80=99s bett= er to use the global variables ($stdin, $stdout, $stderr) rather than the constants (STDIN, STDOUT, STDERR), because you can repoint the variables as you see fit without generating a Ruby warning. For example, when specing my =E2=80=98executable=E2=80=99 classes with RSpe= c, I often want to specify that something should show up on the standard error, and I usually do something like this: module Signore describe Executable do before do @orig_stderr =3D $stderr $stderr =3D StringIO.new end after do $stderr =3D @orig_stderr end def stderr $stderr.rewind $stderr.read end it 'should print usage if no command was given' do lambda { Executable.new([]) }.should raise_error SystemExit stderr.should match /usage: signore prego\|pronto \[label, =E2=80=A6\]/ end # =E2=80=A6 end end =E2=80=94 Shot --=20 a :message to you, Ruby --ibTvN161/egqYuK8 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAksH9wQACgkQi/mCfdEo8UrsigCfT+uVhSS+m/OEsvCMSBxL5pwl t6AAn3asGAdxDsVHvJHhI+QKiume8XI0 =Zgsd -----END PGP SIGNATURE----- --ibTvN161/egqYuK8--