| 1 | package WWW::Deezer::SearchResult; | ||||||||||
| 2 | |||||||||||
| 3 | 5 | our $VERSION = '0.01'; | |||||||||
| 4 | |||||||||||
| 5 | 5 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 5 | ▶ | use WWW::Deezer::Track; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 5 | has 'data' => (is => 'ro'); | |||||||||
| 10 | 5 | has 'total' => (is => 'ro', isa => 'Int'); | |||||||||
| 11 | 5 | has 'request' => (is => 'ro'); | |||||||||
| 12 | 5 | has 'index' => (is => 'rw', isa => 'Int'); | |||||||||
| 13 | 5 | has 'cursor' => (is => 'rw', isa => 'Int', default => 0); | |||||||||
| 14 | 5 | has 'deezer_obj' => (is => 'rw', isa => 'Ref'); | |||||||||
| 15 | |||||||||||
| 16 | 0 | ▶ | sub count { | ||||||||
|
Subroutine
count: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 17 | 0 | my $self = shift; | |||||||||
| 18 | 0 | return scalar @{$self->data}; | |||||||||
| 19 | } | ||||||||||
| 20 | |||||||||||
| 21 | 1 | ▶ | sub first { | ||||||||
|
Subroutine
first: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 22 | 1 | my $self = shift; | |||||||||
| 23 | |||||||||||
| 24 | 1 | $self->_return_by_index(0); | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 0 | ▶ | sub next { | ||||||||
|
Subroutine
next: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 28 | 0 | my $self = shift; | |||||||||
| 29 | 0 | my $cursor = $self->cursor; | |||||||||
| 30 | 0 | $self->cursor($cursor+1); | |||||||||
| 31 | |||||||||||
| 32 | 0 | return $self->_return_by_index($cursor); | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 1 | ▶ | sub _return_by_index { | ||||||||
|
Subroutine
_return_by_index: called CC=2 SCAR=11.6
| |||||||||||
| 36 | 1 | my ($self, $cursor) = @_; | |||||||||
| 37 | |||||||||||
| 38 | 1 | ▶ | return undef unless $self->data->[$cursor]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | |||||||||||
| 40 | 0 | my $track = WWW::Deezer::Track->new($self->data->[$cursor]); | |||||||||
| 41 | 0 | $track->deezer_obj($self->deezer_obj); | |||||||||
| 42 | 0 | $track->set_artist($self->data->[$cursor]->{artist}); | |||||||||
| 43 | 0 | $track->set_album($self->data->[$cursor]->{album}); | |||||||||
| 44 | |||||||||||
| 45 | 0 | return $track; | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 5 | 1; | |||||||||