Google-Tasks
view release on metacpan or search on metacpan
lib/Google/Tasks.pm view on Meta::CPAN
}
return $self;
}
sub move {
my ( $self, $command ) = @_;
croak('Must provide some command value for move()') unless ( defined $command );
if ( $command =~ /^\d+$/ ) {
croak("move() command seems to relocate task out of bounds of current list")
if ( $command and not defined $self->root->tasks->[$command] );
$self->root->_call( {
'action_type' => 'move',
'id' => $self->id,
'source_list' => $self->list_id,
($command) ? (
'dest_parent' => $self->list_id,
'prior_sibling_id' => $self->root->tasks->[$command]->id,
) : (
lib/Google/Tasks.pm view on Meta::CPAN
my @tasks = grep { $_->id ne $self->id } @{ $self->root->tasks };
splice( @tasks, $command, 0, $self );
$self->root->_set_tasks(\@tasks);
}
elsif ( $command eq 'down' ) {
$self->move( ( firstidx { $_->id eq $self->id } @{ $self->root->tasks } ) + 1 );
}
elsif ( $command eq 'up' ) {
my $idx = ( firstidx { $_->id eq $self->id } @{ $self->root->tasks } ) - 1;
croak("move() command seems to relocate task out of bounds of current list")
if ( $idx < 0 );
$self->move($idx);
}
elsif (
ref $command eq 'Google::Tasks::Task' or
ref $command eq 'Google::Tasks::List'
) {
$self->root->_call( {
'action_type' => 'move',
( run in 0.495 second using v1.01-cache-2.11-cpan-5511b514fd6 )