root/trunk/plagger/lib/Plagger/Rule/RecentN.pm

Revision 1925 (checked in by miyagawa, 2 years ago)

Add Rule::RecentN

Line 
1 package Plagger::Rule::RecentN;
2 use strict;
3 use warnings;
4 use base qw( Plagger::Rule );
5
6 sub init {
7     my $self = shift;
8
9     my $number = $self->{count}
10         or Plagger->context->erorr("count is not defined.");
11 }
12
13 sub id {
14     my $self = shift;
15     return "RecentN:$self->{count}";
16 }
17
18 sub dispatch {
19     my($self, $args) = @_;
20
21     my $entry = $args->{entry} or Plagger->context->error('No entry object in this plugin phase');
22     $self->{__entries}->{$args->{feed}->id_safe}++ < $self->{count};
23 }
24
25 1;
26
27 __END__
28
29 =head1 NAME
30
31 Plagger::Rule::RecentN - rule to match recent N entries in the feed
32
33   - module: Filter::Rule
34     rule:
35       - module: RecentN
36         count:  20
37
38 =head1 DESCRIPTION
39
40 This module is a Rule module that matches recent N entries in the
41 feed.
42
43 =head1 AUTHOR
44
45 Tatsuhiko Miyagawa
46
47 =head1 SEE ALSO
48
49 L<Plagger>
50
51 =cut
Note: See TracBrowser for help on using the browser.