WWW::Ruler - a helper for building rulers for visual presentation (in WWW applictions for example)
Now this module is beta. Not all documentation is finished yet.
use WWW::Ruler; my $ruler = WWW::Ruler->new( page_size => $page_size, ruler_size => 15 ); # $page_number - a number of current page # $array_length - a dimension of array of data my $piece = $ruler->cut_off( page_number => $page_number, amount => $array_length ); # Detail in manual WWW::Ruler::Piece(3) $ruler_array = $piece->ruler; # An array of ruler items for drawing $start_index = $piece->start; # A start index of array (a base is zero) for cutting $end_index = $piece->end; # An end index of array (a base is zero) for cutting $size = $piece->size; # A size (dimension) of piece of current page.
This class will help to make a ruler with a following layouts and calculate start and end indices. Ruler can look like these examples:
[ << ] [ 1 ] [ ... ] [ 4 ] [ 5 ] ( 6 ) [ 7 ] [ 8 ] [ ... ] [ 999 ] [ >> ]
( 1 ) [ 4 ] [ 5 ] ( 6 ) [ 7 ] [ 8 ] [ ... ] [ 999 ] [ >> ]
[ << ] [ 1 ] [ ... ] [ 4 ] [ 5 ] ( 6 ) [ 7 ] [ 8 ] [ >> ]
Here ( 1 ) and ( 6 ) are "current" pages. A [ << ], [ >> ] and [ DIGIT ] - linked buttons for other pages for example. And the [ ... ] is an ellipse figure of span between page numbers (not linked).
$ruler = WWW::Ruler->new( page_size => $page_size, ruler_size => 15 ); $ruler = WWW::Ruler->new;
You can construct object with and without options.
Number. How many do you have items in one page?
A desired maximum number of buttons (not included button [<<], [>>] and [...]). It is only desired amount! Please notice that real items in ruler can be up 3-4 items! It option will be improved in next versions.
A current number of page for which this ruler to be builded. It starts from 1.
An amount of items in whole array.
The constructor. The %opts are optional. Any options can be redefined in "cut_off" method.
This method makes virtual cut off of array and contructs array of ruler items. Any options are passed to this method redefine options of constructor.
Returns an instance of WWW::Ruler::Piece object.
This module has been written by Perlover <firstname.lastname@example.org>
This module is free software and is published under the same terms as Perl itself.