~ubuntu-branches/ubuntu/saucy/libpod-pom-perl/saucy

« back to all changes in this revision

Viewing changes to lib/Pod/POM/View.pm

  • Committer: Bazaar Package Importer
  • Author(s): Taku YASUI
  • Date: 2001-06-19 19:56:58 UTC
  • Revision ID: james.westby@ubuntu.com-20010619195658-7klk908yvhfl7gzg
Tags: upstream-0.02
ImportĀ upstreamĀ versionĀ 0.02

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#============================================================= -*-Perl-*-
 
2
#
 
3
# Pod::POM::View
 
4
#
 
5
# DESCRIPTION
 
6
#   Visitor class for creating a view of all or part of a Pod Object 
 
7
#   Model.
 
8
#
 
9
# AUTHOR
 
10
#   Andy Wardley   <abw@kfs.org>
 
11
#
 
12
# COPYRIGHT
 
13
#   Copyright (C) 2000, 2001 Andy Wardley.  All Rights Reserved.
 
14
#
 
15
#   This module is free software; you can redistribute it and/or
 
16
#   modify it under the same terms as Perl itself.
 
17
#
 
18
# REVISION
 
19
#   $Id$
 
20
#
 
21
#========================================================================
 
22
 
 
23
package Pod::POM::View;
 
24
 
 
25
require 5.004;
 
26
 
 
27
use strict;
 
28
use vars qw( $VERSION $DEBUG $ERROR $AUTOLOAD );
 
29
 
 
30
$VERSION = sprintf("%d.%02d", q$Revision: 1.1.1.1 $ =~ /(\d+)\.(\d+)/);
 
31
$DEBUG   = 0 unless defined $DEBUG;
 
32
 
 
33
 
 
34
#------------------------------------------------------------------------
 
35
# new($pom)
 
36
#------------------------------------------------------------------------
 
37
 
 
38
sub new {
 
39
    my $class = shift;
 
40
    my $args  = ref $_[0] eq 'HASH' ? shift : { @_ };
 
41
    bless { %$args }, $class;
 
42
}
 
43
 
 
44
 
 
45
sub print {
 
46
    my ($self, $item) = @_;
 
47
    return UNIVERSAL::can($item, 'present')
 
48
        ? $item->present($self) : $item;
 
49
}
 
50
    
 
51
 
 
52
sub view {
 
53
    my ($self, $type, $node) = @_;
 
54
    return $node;
 
55
}
 
56
 
 
57
 
 
58
sub AUTOLOAD {
 
59
    my $self = shift;
 
60
    my $name = $AUTOLOAD;
 
61
    my $item;
 
62
 
 
63
    $name =~ s/.*:://;
 
64
    return if $name eq 'DESTROY';
 
65
 
 
66
#    my ($pkg, $file, $line) = caller;
 
67
#    print STDERR "called AUTOLOAD $name from $file line $line\n";
 
68
 
 
69
    if ($name =~ s/^view_//) {
 
70
        return $self->view($name, @_);
 
71
    }
 
72
    elsif (! ref $self) {
 
73
        die "can't access $name in $self\n";
 
74
    }
 
75
    else {
 
76
        die "no such method for $self: $name ($AUTOLOAD)"
 
77
            unless defined ($item = $self->{ $name });
 
78
 
 
79
        return wantarray ? ( ref $item eq 'ARRAY' ? @$item : $item ) : $item;
 
80
    }
 
81
}
 
82
 
 
83
 
 
84
1;
 
85
 
 
86
 
 
87
 
 
88