Astro-FITS-CFITSIO-Simple

 view release on metacpan or  search on metacpan

lib/Astro/FITS/CFITSIO/Simple/PrintStatus.pm  view on Meta::CPAN


    sub output {
        my ( $self, $row, $nrows ) = @_;

        $self->{progress}->update( $row );
    }

    sub finish {
        my $self = shift;

        $self->{progress}->update( $self->{nrows} );
    }
}

#
# This file is part of Astro-FITS-CFITSIO-Simple
#
# This software is Copyright (c) 2008 by Smithsonian Astrophysical Observatory.
#
# This is free software, licensed under:
#
#   The GNU General Public License, Version 3, June 2007
#

1;

__END__

=pod

=for :stopwords Diab Jerius Pete Ratzlaff Smithsonian Astrophysical Observatory

=head1 NAME

Astro::FITS::CFITSIO::Simple::PrintStatus - generate a progress status update

=head1 VERSION

version 0.20

=head1 DESCRIPTION

INTERNAL USE ONLY!  No warranty, may change, etc.

=head2 Methods

=over

=item new

  $status = Astro::FITS::CFITSIO::Simple::PrintStatus->new( $what );

Create a new object.  C<$what> may be one of the following:

=over

=item SCALAR

If this is non-zero, a progress indicator is written to STDERR.  If
B<Term::ProgressBar> is available, that is used, else a simple
percentile is output.  If this is zero, returns B<undef>.

=item GLOB

If it's a glob, it's assumed to be a filehandle glob, and output is
written to that filehandle.

=item CODEREF

If it's a code reference, it is called with three arguments

  rows read
  total number of rows

=item OBJECT

If it's an object, and it has B<print()> and B<flush()> methods,
it'll call those as appropriate.

=back

=item start

  $status->start( $nrows );

This preps the output and indicates the number of rows that will be written.

=item update

  $status->update( $rows_read );

This will cause output to be generated.  It returns the number of rows that
will cause an actual change in the output.  It is usually used as such:

  $next_update = 0;
  $ps->start();
  for ( 0..$nmax )
  {
    # do stuff

    $next_update = $ps->update( $_ )
      if $_ >= $next_update;
  }
  $ps->finish
    if $nmax >= $next_update;

=item finish

  $status->finish;

This should be called after all of the rows have been written.

=back

=for Pod::Coverage next_update

=head1 SUPPORT

=head2 Bugs

Please report any bugs or feature requests to bug-astro-fits-cfitsio-simple@rt.cpan.org  or through the web interface at: https://rt.cpan.org/Public/Dist/Display.html?Name=Astro-FITS-CFITSIO-Simple



( run in 1.189 second using v1.01-cache-2.11-cpan-39bf76dae61 )