]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - config/mpfire/perl/Audio/MPD/Common/Item.pm
Finalized core13 and redirector fixes
[people/pmueller/ipfire-2.x.git] / config / mpfire / perl / Audio / MPD / Common / Item.pm
CommitLineData
83d20a45
CS
1#
2# This file is part of Audio::MPD::Common
3# Copyright (c) 2007 Jerome Quelin, all rights reserved.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the same terms as Perl itself.
7#
8#
9
10package Audio::MPD::Common::Item;
11
12use strict;
13use warnings;
14use Audio::MPD::Common::Item::Directory;
15use Audio::MPD::Common::Item::Playlist;
16use Audio::MPD::Common::Item::Song;
17
18#our ($VERSION) = '$Rev: 5645 $' =~ /(\d+)/;
19
20#
21# constructor.
22#
23sub new {
24 my ($pkg, %params) = @_;
25
26 # transform keys in lowercase.
27 my %lowcase;
28 @lowcase{ keys %params } = values %params;
29
30 return Audio::MPD::Common::Item::Song->new(\%lowcase) if exists $params{file};
31 return Audio::MPD::Common::Item::Directory->new(\%lowcase) if exists $params{directory};
32 return Audio::MPD::Common::Item::Playlist->new(\%lowcase) if exists $params{playlist};
33}
34
351;
36
37__END__
38
39
40=head1 NAME
41
42Audio::MPD::Common::Item - a generic collection item
43
44
45=head1 SYNOPSIS
46
47 my $item = Audio::MPD::Common::Item->new( %params );
48
49
50=head1 DESCRIPTION
51
52C<Audio::MPD::Common::Item> is a virtual class representing a generic
53item of mpd's collection. It can be either a song, a directory or a playlist.
54
55Depending on the params given to C<new>, it will create and return an
56C<Audio::MPD::Common::Item::Song>, an C<Audio::MPD::Common::Item::Directory>
57or an C<Audio::MPD::Common::Playlist> object. Currently, the
58discrimination is done on the existence of the C<file> key of C<%params>.
59
60
61=head1 PUBLIC METHODS
62
63Note that the only sub worth it in this class is the constructor:
64
65=over 4
66
67=item new( key => val [, key => val [, ...] ] )
68
69Create and return either an C<Audio::MPD::Common::Item::Song>, an
70C<Audio::MPD::Common::Item::Directory> or an C<Audio::MPD::Common::Playlist>
71object, depending on the existence of a key C<file>, C<directory> or
72C<playlist> (respectively).
73
74=back
75
76
77=head1 SEE ALSO
78
79=over 4
80
81=item L<Audio::MPD>
82
83=item L<POE::Component::Client::MPD>
84
85=back
86
87
88=head1 AUTHOR
89
90Jerome Quelin, C<< <jquelin at cpan.org> >>
91
92
93=head1 COPYRIGHT & LICENSE
94
95Copyright (c) 2007 Jerome Quelin, all rights reserved.
96
97This program is free software; you can redistribute it and/or modify
98it under the same terms as Perl itself.
99
100=cut