| 1 | package oEdtk::Field; | ||
| 2 | |||
| 3 | 5 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 5 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 5 | our $VERSION = 2.1126; | |
| 6 | |||
| 7 | 0 | ▶ | sub new { |
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 8 | 0 | my ( $class, $name, $len ) = @_; | |
| 9 | 0 | my $field = { | |
| 10 | name => $name, | ||
| 11 | len => $len, | ||
| 12 | }; | ||
| 13 | |||
| 14 | 0 | bless $field, $class; | |
| 15 | 0 | return $field; | |
| 16 | } | ||
| 17 | |||
| 18 | 0 | ▶ | sub process { |
|
Subroutine
process: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 19 | 0 | my ( $self, $data ) = @_; | |
| 20 | |||
| 21 | 0 | return $data; | |
| 22 | } | ||
| 23 | |||
| 24 | 0 | ▶ | sub get_name { |
|
Subroutine
get_name: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 25 | 0 | my ($self) = @_; | |
| 26 | |||
| 27 | 0 | return $self->{'name'}; | |
| 28 | } | ||
| 29 | |||
| 30 | 0 | ▶ | sub set_name { |
|
Subroutine
set_name: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 31 | 0 | my ( $self, $name ) = @_; | |
| 32 | |||
| 33 | 0 | $self->{'name'} = $name; | |
| 34 | } | ||
| 35 | |||
| 36 | 0 | ▶ | sub get_len { |
|
Subroutine
get_len: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 37 | 0 | my ($self) = @_; | |
| 38 | |||
| 39 | 0 | return $self->{'len'}; | |
| 40 | } | ||
| 41 | |||
| 42 | 5 | 1; | |
| 43 | |||
| 44 | =head1 NAME | ||
| 45 | |||
| 46 | oEdtk::Field - abstract base class for fixed-width record fields | ||
| 47 | |||
| 48 | =head1 SYNOPSIS | ||
| 49 | |||
| 50 | use base 'oEdtk::Field'; | ||
| 51 | |||
| 52 | my $field = oEdtk::Field->new('NAME', 10); | ||
| 53 | print $field->get_name, "\n"; | ||
| 54 | print $field->process('value'), "\n"; | ||
| 55 | |||
| 56 | =head1 DESCRIPTION | ||
| 57 | |||
| 58 | The root of the field hierarchy used to describe the fixed-width records of an | ||
| 59 | Infinite flux. A field carries a name and a byte length and knows how to turn | ||
| 60 | the raw slice handed to it by C<oEdtk::Record> into a display value. The base | ||
| 61 | class returns the slice unchanged; subclasses (C<oEdtk::AddrField>, | ||
| 62 | C<oEdtk::DateField>, C<oEdtk::FPField>, C<oEdtk::SignedField>) override | ||
| 63 | L</process>. | ||
| 64 | |||
| 65 | =head1 METHODS | ||
| 66 | |||
| 67 | =head2 new | ||
| 68 | |||
| 69 | my $field = oEdtk::Field->new($name, $len); | ||
| 70 | |||
| 71 | Construct a field of name C<$name> and byte length C<$len>. | ||
| 72 | |||
| 73 | =head2 process | ||
| 74 | |||
| 75 | my $value = $field->process($data); | ||
| 76 | |||
| 77 | Return the display value for the raw slice C<$data>. The base implementation is | ||
| 78 | the identity; subclasses override it. | ||
| 79 | |||
| 80 | =head2 get_name | ||
| 81 | |||
| 82 | my $name = $field->get_name; | ||
| 83 | |||
| 84 | Return the field name. | ||
| 85 | |||
| 86 | =head2 set_name | ||
| 87 | |||
| 88 | $field->set_name($name); | ||
| 89 | |||
| 90 | Set the field name. | ||
| 91 | |||
| 92 | =head2 get_len | ||
| 93 | |||
| 94 | my $len = $field->get_len; | ||
| 95 | |||
| 96 | Return the field byte length. | ||
| 97 | |||
| 98 | =head1 AUTHOR | ||
| 99 | |||
| 100 | The oEdtk team. | ||
| 101 | |||
| 102 | =cut | ||