Eric Wilhelm > dotReader-v0.11.2 > List::History

Download:
dotReader-v0.11.2.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  2
Open  1
View/Report Bugs
Source  

NAME ^

List::History - a previous/current/next list of objects

ABOUT ^

This is a history list much like what is implemented in most major browsers.

The position pointer could be in one of several states:

    prev   current    next
  -------  -------  --------
     0        0        0       just started
     1        0        0       clicked a new link
     0        1        1       clicked once and went back
     1        1        0       went back (or forward to end)
     1        1        1       went back twice or more

In other words, there is not a current moment unless you remember() it. The state is saved just before the user leaves the current page.

SYNOPSIS ^

new

  my %details = (
    foo => 1, # gives moment foo(), get_foo(), and set_foo()
    bar => 1, # etc.
  );
  my $hist = List::History->new(moment_spec => {%details});

The moment_spec argument defines the attributes for the moment class, which allows you to use accessors on the stored hashref. Each moment class is particular to a given history object. This is generated for you by the constructor. The values in the hash are currently ignored, but will eventually become some sort of typemap.

Moment-Making Methods ^

add

Add a moment to the history. $hist->has_current will always be false after this method is called.

  $hist->add(%moment_data);

remember

Creates a moment and either replaces the current moment or else makes this one current. (You'll need to call this before going back.)

  $hist->remember(%moment_data);

Boolean Methods ^

These return true if the history has a moment in the given slot.

has_current

  my $bool = $hist->has_current;

has_next

  my $bool = $hist->has_next;

has_prev

  my $bool = $hist->has_prev;

Manipulation Methods ^

foreward

  my $moment = $hist->foreward;

backward

  my $moment = $hist->backward;

get_list

  my @list = $hist->get_list;

get_current

  my $moment = $hist->get_current;

get_moment

  my $moment = $hist->get_moment($index);

clear_future

This is called automatically by add(). Clears the current and future item.

  $hist->clear_future;

Convenience ^

moment

This will typically not be needed since add() and remember() call it for you.

  my $moment = $self->moment(%moment_data);

Private ^

_list

  my $list = $hist->_list;

_inc_pos

  $self->_inc_pos($number);

AUTHOR ^

Eric Wilhelm <ewilhelm at cpan dot org>

http://scratchcomputing.com/

COPYRIGHT ^

Copyright (C) 2006 Eric L. Wilhelm and OSoft, All Rights Reserved.

NO WARRANTY ^

Absolutely, positively NO WARRANTY, neither express or implied, is offered with this software. You use this software at your own risk. In case of loss, no person or entity owes you anything whatsoever. You have been warned.

LICENSE ^

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: