]> git.donarmstrong.com Git - liborg-parser-perl.git/blob - lib/Org/Element/TableRow.pm
Import original source of Org-Parser 0.23
[liborg-parser-perl.git] / lib / Org / Element / TableRow.pm
1 package Org::Element::TableRow;
2
3 use 5.010;
4 use locale;
5 use Moo;
6 extends 'Org::Element';
7
8 our $VERSION = '0.23'; # VERSION
9
10 sub as_string {
11     my ($self) = @_;
12     return $self->_str if defined $self->_str;
13
14     join("",
15          "|",
16          join("|", map {$_->as_string} @{$self->children}),
17          "\n");
18 }
19
20 sub as_array {
21     my ($self) = @_;
22
23     [map {$_->as_string} @{$self->children}];
24 }
25
26 sub cells {
27     my ($self) = @_;
28     return [] unless $self->children;
29
30     my $cells = [];
31     for my $el (@{$self->children}) {
32         push @$cells, $el if $el->isa('Org::Element::TableCell');
33     }
34     $cells;
35 }
36
37 1;
38 # ABSTRACT: Represent Org table row
39
40
41 =pod
42
43 =head1 NAME
44
45 Org::Element::TableRow - Represent Org table row
46
47 =head1 VERSION
48
49 version 0.23
50
51 =head1 DESCRIPTION
52
53 Derived from L<Org::Element>. Must have L<Org::Element::TableCell>
54 instances as its children.
55
56 =head1 ATTRIBUTES
57
58 =head1 METHODS
59
60 =for Pod::Coverage as_string
61
62 =head2 $table->cells() => ELEMENTS
63
64 Return the cells of the row.
65
66 =head2 $table->as_array() => ARRAYREF
67
68 Return an arrayref containing the cells of the row, each cells already
69 stringified with as_string().
70
71 =head1 AUTHOR
72
73 Steven Haryanto <stevenharyanto@gmail.com>
74
75 =head1 COPYRIGHT AND LICENSE
76
77 This software is copyright (c) 2012 by Steven Haryanto.
78
79 This is free software; you can redistribute it and/or modify it under
80 the same terms as the Perl 5 programming language system itself.
81
82 =cut
83
84
85 __END__
86