File Coverage

blib/lib/Treex/PML/Schema/Member.pm
Criterion Covered Total %
statement 33 37 89.1
branch 2 4 50.0
condition 4 12 33.3
subroutine 13 16 81.2
pod 8 8 100.0
total 60 77 77.9


line stmt bran cond sub pod time code
1             package Treex::PML::Schema::Member;
2              
3 9     9   48 use strict;
  9         14  
  9         297  
4 9     9   37 use warnings;
  9         10  
  9         437  
5              
6 9     9   38 use vars qw($VERSION);
  9         11  
  9         429  
7             BEGIN {
8 9     9   193 $VERSION='2.29'; # version template
9             }
10 9     9   33 no warnings 'uninitialized';
  9         11  
  9         303  
11 9     9   34 use Carp;
  9         20  
  9         468  
12              
13 9     9   57 use Treex::PML::Schema::Constants;
  9         13  
  9         865  
14 9     9   39 use base qw( Treex::PML::Schema::Decl );
  9         12  
  9         3631  
15              
16              
17             =head1 NAME
18              
19             Treex::PML::Schema::Member - implements declaration of a member of a structure.
20              
21             =head1 INHERITANCE
22              
23             This class inherits from L.
24              
25             =head1 METHODS
26              
27             See the super-class for the complete list.
28              
29             =over 3
30              
31             =item $decl->get_decl_type ()
32              
33             Returns the constant PML_MEMBER_DECL.
34              
35             =item $decl->get_decl_type_str ()
36              
37             Returns the string 'member'.
38              
39             =item $decl->get_name ()
40              
41             Return name of the member.
42              
43             =item $decl->is_required ()
44              
45             Return 1 if the member is declared as required, 0 otherwise.
46              
47             =item $decl->is_attribute ()
48              
49             Return 1 if the member is declared as attribute, 0 otherwise.
50              
51             =item $decl->get_parent_struct ()
52              
53             Return the structure declaration the member belongs to.
54              
55             =item $decl->get_knit_name ()
56              
57             Return the member's name with a possible suffix '.rf' chopped-off, if
58             either the member itself has a role '#KNIT' or its content is a list
59             and has a role '#KNIT'. Otherwise return just the member's name.
60              
61             =back
62              
63             =cut
64              
65 0     0 1 0 sub is_atomic { undef }
66 2677     2677 1 3439 sub get_decl_type { return PML_MEMBER_DECL; }
67 0     0 1 0 sub get_decl_type_str { return 'member'; }
68 1229     1229 1 2943 sub get_name { return $_[0]->{-name}; }
69 910     910 1 2634 sub is_required { return $_[0]->{required}; }
70 115     115 1 254 sub is_attribute { return $_[0]->{as_attribute}; }
71             *get_parent_struct = \&Treex::PML::Schema::Decl::get_parent_decl;
72              
73             sub validate_object {
74 0     0 1 0 shift->get_content_decl->validate_object(@_);
75             }
76              
77             sub get_knit_name {
78 7     7 1 12 my $self = shift;
79 7         14 my $name = $self->{-name};
80 7         13 my $knit_name = $name;
81 7 50       56 if ($knit_name=~s/\.rf$//) {
82 7         11 my $cont;
83 7 50 33     54 if ( $self->{role} eq '#KNIT' or
      33        
      33        
      33        
84             (($cont = $self->get_content_decl) and
85             ($cont->get_decl_type == PML_LIST_DECL
86             or
87             $cont->get_decl_type == PML_ALT_DECL)
88             and
89             $cont->get_role eq '#KNIT')) {
90 7         25 return $knit_name
91             }
92             }
93 0           return $name;
94             }
95              
96              
97             1;
98             __END__