BASIS  r3148
Sequence.pm
Go to the documentation of this file.
00001 #============================================================= -*-Perl-*-
00002 #
00003 # Pod::POM::Node::Sequence
00004 #
00005 # DESCRIPTION
00006 #   Module implementing specific nodes in a Pod::POM, subclassed from
00007 #   Pod::POM::Node.
00008 #
00009 # AUTHOR
00010 #   Andy Wardley   <abw@kfs.org>
00011 #   Andrew Ford    <a.ford@ford-mason.co.uk>
00012 #
00013 # COPYRIGHT
00014 #   Copyright (C) 2000, 2001 Andy Wardley.  All Rights Reserved.
00015 #   Copyright (C) 2009 Andrew Ford.  All Rights Reserved.
00016 #
00017 #   This module is free software; you can redistribute it and/or
00018 #   modify it under the same terms as Perl itself.
00019 #
00020 # REVISION
00021 #   $Id: Sequence.pm 76 2009-08-20 20:41:33Z ford $
00022 #
00023 #========================================================================
00024 
00025 package BASIS::Pod::POM::Node::Sequence;
00026 
00027 use strict;
00028 
00029 use BASIS::Pod::POM::Constants qw( :all );
00030 use parent qw( BASIS::Pod::POM::Node );
00031 use vars qw( %NAME );
00032 
00033 %NAME = (
00034     C => 'code',
00035     B => 'bold',
00036     I => 'italic',
00037     L => 'link',
00038     S => 'space',
00039     F => 'file',
00040     X => 'index',
00041     Z => 'zero',
00042     E => 'entity',
00043 );
00044     
00045 sub new {
00046     my ($class, $self) = @_;
00047     local $" = '] [';
00048     return bless \$self, $class;
00049 }
00050 
00051 sub add {
00052     return IGNORE;
00053 }
00054 
00055 sub present {
00056     my ($self, $view) = @_;
00057     my ($cmd, $method, $result);
00058     $view ||= $BASIS::Pod::POM::DEFAULT_VIEW;
00059 
00060     $self = $$self;
00061     return $self unless ref $self eq 'ARRAY';
00062 
00063     my $text = join('', 
00064                     map { ref $_ ? $_->present($view) 
00065                                  : $view->view_seq_text($_) } 
00066                     @{ $self->[CONTENT] });
00067     
00068     if ($cmd = $self->[CMD]) {
00069         my $method = $NAME{ $cmd } || $cmd;
00070         $method = "view_seq_$method";
00071         return $view->$method($text);
00072     }
00073     else {
00074         return $text;
00075     }
00076 }
00077 
00078 1;
00079 
00080 =head1 NAME
00081 
00082 Pod::POM::Node::Sequence -
00083 
00084 =head1 SYNOPSIS
00085 
00086     use Pod::POM::Nodes;
00087 
00088 =head1 DESCRIPTION
00089 
00090 This module implements a specialization of the node class to represent sequence elements.
00091 
00092 =head1 AUTHOR
00093 
00094 Andrew Ford E<lt>a.ford@ford-mason.co.ukE<gt>
00095 
00096 Andy Wardley E<lt>abw@kfs.orgE<gt>
00097 
00098 =head1 COPYRIGHT
00099 
00100 Copyright (C) 2000, 2001 Andy Wardley.  All Rights Reserved.
00101 
00102 Copyright (C) 2009 Andrew Ford.  All Rights Reserved.
00103 
00104 This module is free software; you can redistribute it and/or
00105 modify it under the same terms as Perl itself.
00106 
00107 =head1 SEE ALSO
00108 
00109 Consult L<Pod::POM::Node> for a discussion of nodes.