Net::Delicious::Post - OOP for del.icio.us post thingies


Net-Delicious documentation Contained in the Net-Delicious distribution.

Index


Code Index:

NAME

Top

Net::Delicious::Post - OOP for del.icio.us post thingies

SYNOPSIS

Top

  use Net::Delicious;
  my $del = Net::Delicious->new({...});

  foreach my $post ($del->recent_posts()) {

      # $post is a Net::Delicious::Post 
      # object.

      print "$post\n";
  }

DESCRIPTION

Top

OOP for del.icio.us post thingies.

NOTES

Top

PACKAGE METHODS

Top

__PACKAGE__->new(\%args)

Returns a Net::Delicious::Post object. Woot!

OBJECT METHODS

Top

$obj->description()

Returns a string.

$obj->extended()

Returns a string.

$obj->href()

Returns a string.

$obj->tag()

Returns a string.

$obj->tags()

Returns a string.

$obj->user()

Returns a Net::Delicious::User object.

$obj->time()

Returns a string, formatted YYYY-MM-DD

$obj->shared($raw)

Returns a boolean, unless $raw is true in which case the method will return "no" or ""

$obj->as_hashref()

Return the object as a hash ref safe for serializing and re-blessing.

VERSION

Top

1.13

DATE

Top

$Date: 2008/03/03 16:55:04 $

AUTHOR

Top

Aaron Straup Cope <ascope@cpan.org>

SEE ALSO

Top

Net::Delicious

LICENSE

Top

Copyright (c) 2004-2008 Aaron Straup Cope. All rights reserved.

This is free software, you may use it and distribute it under the same terms as Perl itself.


Net-Delicious documentation Contained in the Net-Delicious distribution.
# $Id: Post.pm,v 1.25 2008/03/03 16:55:04 asc Exp $
use strict;

package Net::Delicious::Post;
use base qw (Net::Delicious::Object);

$Net::Delicious::Post::VERSION = '1.14';

use Net::Delicious::User;
use overload q("") => sub { shift->href() };

sub new {
    my $pkg  = shift;
    my $args = shift;
    
    my $self = $pkg->SUPER::new($args);

    # this one seems to be the source of some
    # confusion - unclear whether it's me or
    # inconsistency in the API itself

    $self->{tags} ||= $args->{ tag };

    $self->{user} = Net::Delicious::User->new({name => $args->{user}});
    return $self;
}

# Defined in Net::Delicious::Object

# Defined in Net::Delicious::Object

# Defined in Net::Delicious::Object

sub url {
        return shift->href();
}

sub link {
        return shift->href();
}

# Defined in Net::Delicious::Object

sub tags {
    return shift->tag();
}

sub user {
        return shift->{user};
}

# Defined in Net::Delicious::Object

sub shared {
        my $self = shift;
        my $raw  = shift;

        if ($raw) {
                return $self->{shared};
        }

        return ($self->{shared} eq "no") ? 0 : 1;
}

sub as_hashref {
        my $self = shift;

        my $data      = $self->SUPER::as_hashref();
        $data->{user} = $self->user()->name();

        return $data;
}

return 1;