Jonathan Yu > WWW-OPG-1.005 > WWW::OPG

Download:
WWW-OPG-1.005.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 1.005   Source  

NAME ^

WWW::OPG - Perl interface to Ontario Power Generation's site

VERSION ^

Version 1.005 ($Id: OPG.pm 11016 2010-01-16 06:11:43Z FREQUENCY@cpan.org $)

SYNOPSIS ^

  use WWW::OPG;

  my $opg = WWW::OPG->new();
  eval {
    $opg->poll();
  };
  print "Currently generating ", $opg->power, "MW of electricity\n";

DESCRIPTION ^

This module provides a Perl interface to information published on Ontario Power Generation's web site at http://www.opg.com. This module provides very quick and low-bandwidth queries using the special machine-readable file proffered by OPG; see http://www.opg.com/megafile.txt.

COMPATIBILITY ^

This module was tested under Perl 5.10.1, using Debian Linux. However, because it's Pure Perl and doesn't do anything too obscure, it should be compatible with any version of Perl that supports its prerequisite modules.

If you encounter any problems on a different version or architecture, please contact the maintainer.

METHODS ^

new

  WWW::OPG->new( \%params )

Initialize a WWW::OPG object, setting up the user agent and preparing for a transaction. Note that you can pass a LWP::UserAgent object or a subclass thereof, which can include your proxy or UserAgent settings.

Example code:

  my $opg = WWW::OPG->new();
  # or, with some parameters:
  my $opg = WWW::OPG->new({
    useragent => LWP::UserAgent->new()
  });

This method will return an appropriate WWW::OPG object or throw an exception on error.

poll

  $opg->poll()

Update data in the WWW::OPG object, $obj, by connecting to the OPG site and scraping data. The data can then be extracted using the other methods available in this class.

Example code:

  $opg->poll();

This method will return a true value if an update has been performed, a false value if the data is unchanged since the last update, or throw an exception on error.

power

  $opg->power()

Returns the amount of power being generated by Ontario Power Generation (OPG) plants, in MegaWatts (MW).

Example code:

  $opg->poll();
  print "Currently generating ", $opg->power, " MW for Ontario\n";

Note that this value may be undefined if the server has not yet been polled, or if there was a failure polling.

last_updated

  $opg->last_updated()

Returns the date and time that the data was last updated (as defined by the remote OPG web server), given as a DateTime object.

Example code:

  $opg->poll();
  print "Last updated ", $opg->last_updated, "\n";

AUTHOR ^

Jonathan Yu <jawnsy@cpan.org>

CONTRIBUTORS

Your name here ;-)

ACKNOWLEDGEMENTS ^

SUPPORT ^

You can find documentation for this module with the perldoc command.

    perldoc WWW::OPG

You can also look for information at:

REPOSITORY ^

You can access the most recent development version of this module at:

http://svn.ali.as/cpan/trunk/WWW-OPG

If you are a CPAN developer and would like to make modifications to the code base, please contact Adam Kennedy <adamk@cpan.org>, the repository administrator. I only ask that you contact me first to discuss the changes you wish to make to the distribution.

FEEDBACK ^

Please send relevant comments, rotten tomatoes and suggestions directly to the maintainer noted above.

If you have a bug report or feature request, please file them on the CPAN Request Tracker at http://rt.cpan.org. If you are able to submit your bug report in the form of failing unit tests, you are strongly encouraged to do so.

SEE ALSO ^

http://www.opg.com, the Ontario Power Generation web site.

CAVEATS ^

KNOWN BUGS

There are no known bugs as of this release.

LIMITATIONS

QUALITY ASSURANCE METRICS ^

TEST COVERAGE

  File                     stmt   bran   cond   sub    pod   total
  ----------------------- ------ ------ ------ ------ ------ ------
  lib/WWW/OPG.pm           92.9   71.4   66.7  100.0  100.0   87.1

LICENSE ^

In a perfect world, I could just say that this package and all of the code it contains is Public Domain. It's a bit more complicated than that; you'll have to read the included LICENSE file to get the full details.

DISCLAIMER OF WARRANTY ^

The software is provided "AS IS", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.

syntax highlighting: