Spreadsheet::Engine::Value - A value/type combination


Spreadsheet-Engine documentation Contained in the Spreadsheet-Engine distribution.

Index


Code Index:

NAME

Top

Spreadsheet::Engine::Value - A value/type combination

SYNOPSIS

Top

  my $op = Spreadsheet::Engine::Value->new(
    type => 'n',
    value => 10,
  );

  my $type = $op->type;
  my $value = $op->value;

  if ($op->is_txt) { ... }
  if ($op->is_num) { ... }
  if ($op->is_number) { ... }
  if ($op->is_blank) { ... }
  if ($op->is_logical) { ... }
  if ($op->is_error) { ... }
  if ($op->is_na) { ... }

DESCRIPTION

Top

In a spreadsheet, values also have an accompanying type. This class represents such a value/type combination.

CONSTRUCTOR

Top

new

Instantiate with a type and value.

INSTANCE VARIABLES

Top

type / value

The value and type.

METHODS

Top

is_txt

Does this have a textual type (of any subtype)?

is_num

Does this have a numberic type (of any subtype)?

is_number

Is this a number (type 'n', no subtype)?

is_blank

Is this blank?

is_logical

Is this a logical value (true/false)?

is_error

Is this an error?

is_na

Is this N/A?

HISTORY

Top

This code was created for Spreadsheet::Engine 0.11

COPYRIGHT

Top

LICENCE

Top

The contents of this file are subject to the Artistic License 2.0; you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.perlfoundation.org/artistic_license_2_0


Spreadsheet-Engine documentation Contained in the Spreadsheet-Engine distribution.
package Spreadsheet::Engine::Value;

use strict;
use warnings;

use Class::Struct;
struct type => '$', value => '$';

sub is_txt {
  my $self = shift;
  substr($self->type, 0, 1) eq 't';
}

sub is_num {
  my $self = shift;
  substr($self->type, 0, 1) eq 'n';
}

sub is_number {
  my $self = shift;
  $self->type eq 'n';
}

sub is_blank {
  my $self = shift;
  $self->type eq 'b';
}

sub is_logical {
  my $self = shift;
  $self->type eq 'nl';
}

sub is_error {
  my $self = shift;
  substr($self->type, 0, 1) eq 'e';
}

sub is_na {
  my $self = shift;
  $self->type eq 'e#N/A';
}

1;