Mark Allen > Net-API-Gett-1.06 > Net::API::Gett::Share

Download:
Net-API-Gett-1.06.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 1.06   Source  

NAME ^

Net::API::Gett::Share - Gett share object

PURPOSE ^

Encapsulate Gett shares. You normally shouldn't instantiate this class on its own, as the library will create and return this object as appropriate.

ATTRIBUTES ^

user

Net::API::Gett::User object. has_user() predicate.

request

Net::API::Gett::Request object.

sharename

Scalar string. Read only.

title

Scalar string.

created

Scalar integer. Read only. This value is in Unix epoch seconds, suitable for use in a call to localtime().

getturl

Scalar string. The URL to use in a browser to access a share.

files

This attribute holds any Net::API::Gett:File objects linked to a particular share instance. It returns a list of Net::API::Gett:File objects if there are any, otherwise returns an empty list. See also get_file_iterator() below.

METHODS ^

add_file()

This method stores a new Net::API::Gett::File object in the share object. It returns undef if the value passed is not an Net::API::Gett::File object.

file_iterator()

This method returns a Array::Iterator object on the files in this share. For full details about Array::Iterator please read its documentation. It supports standard iterator methods such as:

  • next()
  • has_next()
  • get_next()
  • peek()

Example code using peek:

  my $share = $gett->get_share("4ddsfds");
  my $file_iter = $share->file_iterator();

  while ( $file_iter->has_next ) {
    if ( $file_iter->peek->size > 1_048_576 ) {
      # Skip big file
      warn $file_iter->peek->filename . " is too large, skipping\n";
      $file_iter->next();
    } 
    else {
      my $file = $file_iter->next();
      printf "name: %s\tsize: %d\n", $file->filename, $file->size;
    }
  }

Example code using get_next:

  for my $file ( $file_iter->get_next() ) {
    say "name: " . $file->filename . "\tsize: " . $file->size;
  }

This method returns undef if there are no files associated with a share.

update()

This method updates share attributes. At present, only the share title can be changed (or deleted), so pass in a string to set a new title for a specific share.

Calling this method with an empty parameter list or explicitly passing undef will delete any title currently set on the share.

Returns a Net::API::Gett:Share object with updated values.

destroy()

This method destroys the share and all of the share's files. Returns a true boolean on success.

SEE ALSO ^

Net::API::Gett, Array::Iterator

syntax highlighting: