[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Test if a file is a text file?

stephen O'D

7/4/2007 9:13:00 PM

Guys,

In Perl I can test if a file is a text file using the -T operator. Is
there a way to do the same thing in Ruby?

I know that File.file? tests for a plain file. I also came across
test('f', 'filename') which does the same thing, but doesn't accept T
as a parameter.

Any pointers are greatly appreciated!

Thanks,

Stephen.

1 Answer

Chris Shea

7/4/2007 9:41:00 PM

0

On Jul 4, 3:13 pm, stephen O'D <stephen.odonn...@gmail.com> wrote:
> Guys,
>
> In Perl I can test if a file is a text file using the -T operator. Is
> there a way to do the same thing in Ruby?
>
> I know that File.file? tests for a plain file. I also came across
> test('f', 'filename') which does the same thing, but doesn't accept T
> as a parameter.
>
> Any pointers are greatly appreciated!
>
> Thanks,
>
> Stephen.

This has come up a few times before on this list. You could search
the archives:
http://groups.google.com/group/comp.lang.ruby/search?group=comp.lang.ruby&q=perl+text+binary+file&qt_g=Search+...

You'll find that every once in a while someone posts code to do what
Perl does:
http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/31a720e8409c2153/9ac698f82c6c0496?lnk=gst&q=perl+text+binary+file&rnum=2#9ac698...

There's an awful lot of discussion about this, very handily indexed by
search engines.

HTH,
Chris