POE::Component::ICal - Schedule POE events using rfc2445 recurrences
version 0.130020
use strict; use warnings; use POE; use POE::Component::ICal; my $count = 5; POE::Session->create ( inline_states => { _start => sub { print "_start\n"; $_[HEAP]{count} = $count; POE::Component::ICal->add(tick => { freq => 'secondly', interval => 1 }); }, tick => sub { print "tick: ' . --$_[HEAP]{count}\n"; POE::Component::ICal->remove('tick') if $_[HEAP]{count} == 0; }, _stop => sub { print "_stop\n"; } } ); POE::Kernel->run;
This component extends POE::Component::Schedule by adding an easy way to specify event schedules using rfc2445 recurrence.
See DateTime::Event::ICal for the syntax, the list of the authorized parameters and their use.
This method allows to verify the validity of a rfc2445 recurrence.
$ical - HASHREF - The rfc2445 recurrence.
$ical
Three cases:
my $ical = { freq => 'secondly', interval => 2 }; POE::Component::ICal->verify( $ical );
In case of not validity, an exception is raised.
my $is_valid = POE::Component::ICal->verify( $ical );
A true or false value is returned.
my ($is_valid, $value) = POE::Component::ICal->verify( $ical );
In case of not validity, $value contains the error message otherwise a DateTime::Set instance.
This method add a schedule.
$schedule - SCALAR - The schedule name.
$schedule
$event - SCALAR - The event name.
$event
@args - optional - The optional list of the arguments.
@args
A schedule handle. See POE::Component::Schedule.
The schedule name must be unique by session.
When the rfc2445 parameter dtstart is not specify, this method add it with the DateTime->now() value.
dtstart
DateTime->now()
POE::Component::ICal->add_schedule ( 'tick' # schedule name , clock => { freq => 'secondly', interval => 1 } # event name => ical , 'tick' # ARG0 (Optional) , \$tick_count # ARG1 (Optional) ); POE::Component::ICal->add_schedule ( 'tock' # schedule name , clock => { freq => 'secondly', interval => 2 } # event name => ical , 'tock' # ARG0 (Optional) , \$tock_count # ARG1 (Optional) );
This method calls add_schedule() with schedule name equal to event name.
add_schedule()
See add_schedule().
POE::Component::ICal->add_schedule('tick', tick => { freq => 'secondly', interval => 5 }); POE::Component::ICal->add( tick => { freq => 'secondly', interval => 5 });
This method remove a schedule.
POE::Component::ICal->add_schedule('tock', clock => { freq => 'secondly', interval => 1 }); POE::Component::ICal->remove('tock'); POE::Component::ICal->add(tick => { freq => 'secondly', interval => 1 }); POE::Component::ICal->remove('tick');
This method remove all schedules from the active session.
The section 4.3.10 of rfc2445: http://www.apps.ietf.org/rfc/rfc2445.html.
Loïc TROCHET <losyme@cpan.org>
This software is copyright (c) 2011 by Loïc TROCHET.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install POE::Component::ICal, copy and paste the appropriate command in to your terminal.
cpanm
cpanm POE::Component::ICal
CPAN shell
perl -MCPAN -e shell install POE::Component::ICal
For more information on module installation, please visit the detailed CPAN module installation guide.