| 1 | package Data::Grid::Cell; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use 5.014; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use warnings FATAL => 'all'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 1 | ▶ | use overload '0+' => 'value'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use overload '""' => 'value'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use overload 'bool' => 'value'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 1 | extends 'Data::Grid::Container'; | |||||||||
| 14 | |||||||||||
| 15 | |||||||||||
| 16 | =head1 NAME | ||||||||||
| 17 | |||||||||||
| 18 | Data::Grid::Cell - Cell implementation for Data::Grid::Row | ||||||||||
| 19 | |||||||||||
| 20 | =head1 VERSION | ||||||||||
| 21 | |||||||||||
| 22 | Version 0.06 | ||||||||||
| 23 | |||||||||||
| 24 | =cut | ||||||||||
| 25 | |||||||||||
| 26 | 1 | our $VERSION = '0.06'; | |||||||||
| 27 | |||||||||||
| 28 | |||||||||||
| 29 | =head1 SYNOPSIS | ||||||||||
| 30 | |||||||||||
| 31 | for my $cell (@$cells) { | ||||||||||
| 32 | warn $cell->value; | ||||||||||
| 33 | |||||||||||
| 34 | # string overload | ||||||||||
| 35 | printf "%s\n", $cell; | ||||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | =head1 METHODS | ||||||||||
| 39 | |||||||||||
| 40 | =head2 value | ||||||||||
| 41 | |||||||||||
| 42 | Retrieves a representation of the value of the cell, potentially | ||||||||||
| 43 | formatted by the source, versus a possible alternate L</literal> | ||||||||||
| 44 | value. This method is a I<stub>, and should be defined in a driver | ||||||||||
| 45 | subclass. If the cell is stringified, compared numerically or tested | ||||||||||
| 46 | for truth, this is the method that is called, like so: | ||||||||||
| 47 | |||||||||||
| 48 | print "$cell\n"; # stringification overloaded | ||||||||||
| 49 | |||||||||||
| 50 | =cut | ||||||||||
| 51 | |||||||||||
| 52 | 0 | ▶ | sub value { | ||||||||
|
Subroutine
value: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 53 | 0 | Carp::croak("Somebody forgot to override this method."); | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | =head2 literal | ||||||||||
| 57 | |||||||||||
| 58 | Spreadsheets tend to have a literal value underlying a formatted value | ||||||||||
| 59 | in a cell, which is why we have this class and are not just using | ||||||||||
| 60 | scalars to represent cells. If your driver has literal values, | ||||||||||
| 61 | override this method, otherwise it is a no-op. | ||||||||||
| 62 | |||||||||||
| 63 | =cut | ||||||||||
| 64 | |||||||||||
| 65 | 0 | ▶ | sub literal { | ||||||||
|
Subroutine
literal: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 66 | 0 | $_[0]->value; | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | =head2 quoted | ||||||||||
| 70 | |||||||||||
| 71 | Returns the value with quotes, per L<RFC | ||||||||||
| 72 | 4180|https://tools.ietf.org/html/rfc4180>, if it needs to be quoted. | ||||||||||
| 73 | |||||||||||
| 74 | =cut | ||||||||||
| 75 | |||||||||||
| 76 | 0 | ▶ | sub quoted { | ||||||||
|
Subroutine
quoted: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 77 | 0 | my $val = $_[0]->value; | |||||||||
| 78 | |||||||||||
| 79 | # rfc4180 | ||||||||||
| 80 | 0 | ▶ | if ($val =~ /[",\x0a\x0d]/sm) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 81 | 0 | $val =~ s/"/""/g; | |||||||||
| 82 | 0 | $val = '"' . $val . '"'; | |||||||||
| 83 | } | ||||||||||
| 84 | |||||||||||
| 85 | 0 | $val; | |||||||||
| 86 | } | ||||||||||
| 87 | |||||||||||
| 88 | |||||||||||
| 89 | =head2 row | ||||||||||
| 90 | |||||||||||
| 91 | Alias for L<Data::Grid::Container/parent>. | ||||||||||
| 92 | |||||||||||
| 93 | =cut | ||||||||||
| 94 | |||||||||||
| 95 | 0 | ▶ | sub row { | ||||||||
|
Subroutine
row: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 96 | 0 | $_[0]->parent; | |||||||||
| 97 | } | ||||||||||
| 98 | |||||||||||
| 99 | =head1 AUTHOR | ||||||||||
| 100 | |||||||||||
| 101 | Dorian Taylor, C<< <dorian at cpan.org> >> | ||||||||||
| 102 | |||||||||||
| 103 | =head1 SEE ALSO | ||||||||||
| 104 | |||||||||||
| 105 | =over 4 | ||||||||||
| 106 | |||||||||||
| 107 | =item | ||||||||||
| 108 | |||||||||||
| 109 | L<Data::Grid> | ||||||||||
| 110 | |||||||||||
| 111 | =item | ||||||||||
| 112 | |||||||||||
| 113 | L<Data::Grid::Container> | ||||||||||
| 114 | |||||||||||
| 115 | =item | ||||||||||
| 116 | |||||||||||
| 117 | L<Data::Grid::Table> | ||||||||||
| 118 | |||||||||||
| 119 | =item | ||||||||||
| 120 | |||||||||||
| 121 | L<Data::Grid::Row> | ||||||||||
| 122 | |||||||||||
| 123 | =back | ||||||||||
| 124 | |||||||||||
| 125 | =head1 COPYRIGHT & LICENSE | ||||||||||
| 126 | |||||||||||
| 127 | Copyright 2010-2018 Dorian Taylor. | ||||||||||
| 128 | |||||||||||
| 129 | Licensed under the Apache License, Version 2.0 (the "License"); you | ||||||||||
| 130 | may not use this file except in compliance with the License. You may | ||||||||||
| 131 | obtain a copy of the License at | ||||||||||
| 132 | L<http://www.apache.org/licenses/LICENSE-2.0>. | ||||||||||
| 133 | |||||||||||
| 134 | Unless required by applicable law or agreed to in writing, software | ||||||||||
| 135 | distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||
| 136 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||||||||||
| 137 | implied. See the License for the specific language governing | ||||||||||
| 138 | permissions and limitations under the License. | ||||||||||
| 139 | |||||||||||
| 140 | =cut | ||||||||||
| 141 | |||||||||||
| 142 | 1 | 1; # End of Data::Grid::Cell | |||||||||