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 8     8   53 use strict;
  8         15  
  8         301  
4 8     8   37 use warnings;
  8         16  
  8         474  
5              
6 8     8   45 use vars qw($VERSION);
  8         15  
  8         423  
7             BEGIN {
8 8     8   271 $VERSION='2.28'; # version template
9             }
10 8     8   39 no warnings 'uninitialized';
  8         14  
  8         402  
11 8     8   43 use Carp;
  8         14  
  8         678  
12              
13 8     8   72 use Treex::PML::Schema::Constants;
  8         12  
  8         933  
14 8     8   47 use base qw( Treex::PML::Schema::Decl );
  8         13  
  8         4111  
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 2611     2611 1 4435 sub get_decl_type { return PML_MEMBER_DECL; }
67 0     0 1 0 sub get_decl_type_str { return 'member'; }
68 1201     1201 1 3763 sub get_name { return $_[0]->{-name}; }
69 870     870 1 3064 sub is_required { return $_[0]->{required}; }
70 115     115 1 394 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 17 my $self = shift;
79 7         24 my $name = $self->{-name};
80 7         20 my $knit_name = $name;
81 7 50       94 if ($knit_name=~s/\.rf$//) {
82 7         17 my $cont;
83 7 50 33     49 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         37 return $knit_name
91             }
92             }
93 0           return $name;
94             }
95              
96              
97             1;
98             __END__