| 1 | package Slackware::Slackget::MediaList; | ||
| 2 | |||
| 3 | 3 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 3 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 3 | require Slackware::Slackget::List; | |
| 7 | |||
| 8 | =head1 NAME | ||
| 9 | |||
| 10 | Slackware::Slackget::MediaList - A container of Slackware::Slackget::Media object | ||
| 11 | |||
| 12 | =head1 VERSION | ||
| 13 | |||
| 14 | Version 1.0.0 | ||
| 15 | |||
| 16 | =cut | ||
| 17 | |||
| 18 | 3 | our $VERSION = '0.9.11'; | |
| 19 | 3 | our @ISA = qw( Slackware::Slackget::List ); | |
| 20 | |||
| 21 | =head1 SYNOPSIS | ||
| 22 | |||
| 23 | This class is used by slack-get to represent a list of medias store in the medias.xml file. | ||
| 24 | |||
| 25 | use Slackware::Slackget::MediaList; | ||
| 26 | |||
| 27 | my $list = Slackware::Slackget::MediaList->new(); | ||
| 28 | ... | ||
| 29 | |||
| 30 | =cut | ||
| 31 | |||
| 32 | sub new | ||
| 33 | 0 | ▶ | { |
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||
| 34 | 0 | my ($class,%args) = @_ ; | |
| 35 | 0 | my $self={list_type => 'Slackware::Slackget::Media','root-tag' => 'media-list'}; | |
| 36 | 0 | foreach (keys(%args)) | |
| 37 | { | ||
| 38 | 0 | $self->{$_} = $args{$_}; | |
| 39 | } | ||
| 40 | 0 | bless($self,$class); | |
| 41 | 0 | return $self; | |
| 42 | } | ||
| 43 | |||
| 44 | =head1 CONSTRUCTOR | ||
| 45 | |||
| 46 | =head2 new | ||
| 47 | |||
| 48 | Please read the L<Slackware::Slackget::List> documentation for more informations on the list constructor. | ||
| 49 | |||
| 50 | =head1 FUNCTIONS | ||
| 51 | |||
| 52 | This class inheritate from Slackware::Slackget::List, so have a look to this class for a complete list of methods. | ||
| 53 | |||
| 54 | =cut | ||
| 55 | |||
| 56 | =head2 index_list | ||
| 57 | |||
| 58 | Create an index on the MediaList. This index don't take many memory but speed a lot search, especially when you already have the media shortname ! | ||
| 59 | |||
| 60 | The index is build with the media shortname. | ||
| 61 | |||
| 62 | $list->index_list() ; | ||
| 63 | |||
| 64 | =cut | ||
| 65 | |||
| 66 | sub index_list | ||
| 67 | 0 | ▶ | { |
|
Subroutine
index_list: not called CC=2 SCAR=17.9
Pod
documented
| |||
| 68 | 0 | my $self = shift ; | |
| 69 | 0 | $self->{INDEX} = {} ; | |
| 70 | 0 | foreach my $media (@{$self->{LIST}}) | |
| 71 | { | ||
| 72 | 0 | $self->{INDEX}->{$media->shortname()} = $media ; | |
| 73 | } | ||
| 74 | 0 | return 1; | |
| 75 | } | ||
| 76 | |||
| 77 | =head2 get_indexed | ||
| 78 | |||
| 79 | Return a media, as well as Get() do but use the index to return it quickly. You must provide a media shortname to this method. | ||
| 80 | |||
| 81 | my $media = $list->get_indexed('slackware') ; | ||
| 82 | |||
| 83 | =cut | ||
| 84 | |||
| 85 | sub get_indexed | ||
| 86 | 0 | ▶ | { |
|
Subroutine
get_indexed: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 87 | 0 | my ($self, $id) = @_ ; | |
| 88 | 0 | return $self->{INDEX}->{$id} ; | |
| 89 | } | ||
| 90 | |||
| 91 | =head1 AUTHOR | ||
| 92 | |||
| 93 | DUPUIS Arnaud, C<< <a.dupuis@infinityperl.org> >> | ||
| 94 | |||
| 95 | =head1 BUGS | ||
| 96 | |||
| 97 | Please report any bugs or feature requests to | ||
| 98 | C<bug-Slackware-Slackget@rt.cpan.org>, or through the web interface at | ||
| 99 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Slackware-Slackget>. | ||
| 100 | I will be notified, and then you'll automatically be notified of progress on | ||
| 101 | your bug as I make changes. | ||
| 102 | |||
| 103 | =head1 SUPPORT | ||
| 104 | |||
| 105 | You can find documentation for this module with the perldoc command. | ||
| 106 | |||
| 107 | perldoc Slackware::Slackget::MediaList | ||
| 108 | |||
| 109 | |||
| 110 | You can also look for information at: | ||
| 111 | |||
| 112 | =over 4 | ||
| 113 | |||
| 114 | =item * Infinity Perl website | ||
| 115 | |||
| 116 | L<http://www.infinityperl.org/category/slack-get> | ||
| 117 | |||
| 118 | =item * slack-get specific website | ||
| 119 | |||
| 120 | L<http://slackget.infinityperl.org> | ||
| 121 | |||
| 122 | =item * RT: CPAN's request tracker | ||
| 123 | |||
| 124 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Slackware-Slackget> | ||
| 125 | |||
| 126 | =item * AnnoCPAN: Annotated CPAN documentation | ||
| 127 | |||
| 128 | L<http://annocpan.org/dist/Slackware-Slackget> | ||
| 129 | |||
| 130 | =item * CPAN Ratings | ||
| 131 | |||
| 132 | L<http://cpanratings.perl.org/d/Slackware-Slackget> | ||
| 133 | |||
| 134 | =item * Search CPAN | ||
| 135 | |||
| 136 | L<http://search.cpan.org/dist/Slackware-Slackget> | ||
| 137 | |||
| 138 | =back | ||
| 139 | |||
| 140 | =head1 ACKNOWLEDGEMENTS | ||
| 141 | |||
| 142 | Thanks to Bertrand Dupuis (yes my brother) for his contribution to the documentation. | ||
| 143 | |||
| 144 | =head1 COPYRIGHT & LICENSE | ||
| 145 | |||
| 146 | Copyright 2005 DUPUIS Arnaud, All Rights Reserved. | ||
| 147 | |||
| 148 | This program is free software; you can redistribute it and/or modify it | ||
| 149 | under the same terms as Perl itself. | ||
| 150 | |||
| 151 | =cut | ||
| 152 | |||
| 153 | 3 | 1; # End of Slackware::Slackget::MediaList | |