Equivalent ruby for this perl?

IO.popen("#{COCOA_DIALOG} progressbar",'w') do |pbar|
  pbar.puts "5 We're at 5%"
end

or

pbar = IO.popen(...,'w')
pbar.puts "5 We're at 5%"
pbar.close

Hope that helps.

- Greg

Ezra Zygmuntowicz wrote:

···

Hey there list-
    I'm writing some simple gui's for some ruby scripts with Pashua and
Cocoa Dialogs. I need a little help with a perl example that I want to
convert to ruby. Any help is much appreciated.

Here is the perl code:

#!/usr/bin/perl -w

use strict;
use IO::File;

our $COCOA_DIALOG = "$ENV{HOME}/Applications/CocoaDialog.app/Contents/
MacOS/CocoaDialog";
die "$COCOA_DIALOG doesn't exist" unless -e $COCOA_DIALOG;

###
### EXAMPLE 1
###

### Open a pipe to the program
my $fh = IO::File->new("|$COCOA_DIALOG progressbar");
die "no fh" unless defined $fh;
$fh->autoflush(1);

my $percent = 0;
for (my $percent = 0; $percent <= 100; $percent++) {
    if (!($percent % 5)) {
        ### Update the progressbar and its label every 5%
        print $fh "$percent we're at $percent%\n";
    } else {
        ### Update the progressbar every percent
        print $fh "$percent\n";
    }
    ### simulate a long operation
    1 for (0 .. 90_000);
}

### Close the filehandle to send an EOF
$fh->close();

Now the loops and most of the structure I am fine with. It's mainly
the IO::File->new part that I need to know the ruby equivalent of. It
is basically just a named pipe if I did it in a shell script. What is
the ruby command for a named pipe?

Thanks-
-Ezra Zygmuntowicz
Yakima Herald-Republic
WebMaster
509-577-7732
ezra@yakima-herald.com