Tony Bowden > Spreadsheet-Engine > Spreadsheet::Engine::Fn::base

Download:
Spreadsheet-Engine-0.14.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

Spreadsheet::Engine::Fn::base - base class for spreadsheet functions

SYNOPSIS ^

  use base 'Spreadsheet::Engine::Fn::text';

DESCRIPTION ^

This provides a base class for spreadsheet functions.

Each function will generally have an intermediate base class that extends this with methods specific to the type of function that it is providing.

CONSTRUCTOR ^

new

Instantiates with the given variables.

INSTANCE VARIABLES ^

fname / operand / foperand / errortext / typelookup / sheetdata

As per SocialCalc (to document fully later)

METHODS TO SUBCLASS ^

argument_count

Each function should declare how many arguments it expects. This should be 0 for no arguments, a positive integer for exactly that many arguments, or a negative integer for at least that many arguments (based on the absolute value).

In the latter case, an optional second value will declare a maximum number of arguments (e.g. return (-2, 4) = between 2 and 4 arguments)

If this method is not provided no checking of arguments is performed.

signature (EXPERIMENTAL)

Functions may also declare a signature function that declares, for each operand that the function can receive, whether it must be 't' (text), 'n' (numeric), or in the case of a number, a test ('>0', '<=1') that it must pass. The entire operand stack can then be popped as $self->_ops, throwing an "Invalid arguments" error if required.

result

Functions should provide a result() method that will return a value/type hash containing the calculated response.

result_type

This will normally be calculated based on a lookup of the types of operands provided, but subclasses can override this.

METHODS ^

execute

This delegates to the response() method in the subclass, and pushes the response onto the stack.

next_operand / next_operand_as_text / next_operand_as_number

        my $op = $self->next_operand
        print $op->{value} => $op->{type};

Pops the top of the operand stack and returns a hash containing the value and type. (This is currently a simple delegation to Sheet::operand_value_and_type/operand_as_text/operand_as_number

next_operand_as_text also encodes its return value as utf8.

top_of_stack

Fetch the next operand using top_of_stack_value_and_type(). (This deals differently with ranges and co-ordinates.)

optype

        my $type = $self->optype('twoargnumeric', $op1, $op2);

Returns the resulting value type when doing an operation.

HISTORY ^

This is a Modified Version of code extracted from SocialCalc::Functions in SocialCalc 1.1.0

COPYRIGHT ^

Portions (c) Copyright 2005, 2006, 2007 Software Garden, Inc. All Rights Reserved.

Portions (c) Copyright 2007 Socialtext, Inc. All Rights Reserved.

Portions (c) Copyright 2007, 2008 Tony Bowden

LICENCE ^

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

syntax highlighting: