Module: LXL

Defined in:
lib/lxl.rb

Overview

LXL (Like Excel) is a mini-language that mimics Microsoft Excel formulas. Easily extended with new constants and functions.

Constants

TRUE  # true
FALSE # false
NULL  # nil

Operators

a +  b # Add
a -  b # Subtract
a *  b # Multiply
a /  b # Divide
a =  b # Equal to
a <> b # Not equal to
a <  b # Less than
a >  b # Greater than
a <= b # Less than or equal to
a >= b # Greater than or equal to

Logical Functions

AND (a,b)
OR  (a,b)
IF  (cond,true,false)

Date/Time Functions

TODAY    ()      # current date value
NOW      ()      # current date/time value
DATE     (y,m,d) # date value
TIME     (h,m,s) # time value
DATETIME (value) # convert a date/time string into a date/time value

List Functions

LIST (a,b,..)    # Variable length list
IN   (find,list) # True if find value is found in the given list (works on strings too)

Notes

* The number zero is interpereted as FALSE
* Return multiple results in an array by separating formulas with a semi-colon (;)

Lexical Types

w  Whitespace (includes Commas)
;  Semi-Colon (statement separator)
o  Operator
i  Integer
f  Float
t  Token
s  String (single quoted)
S  String (double quoted)
(  Open (
)  Close )
C  Constant
F  Function

Defined Under Namespace

Classes: LittleLexer, Parser

Class Method Summary collapse

Class Method Details

.eval(formula) ⇒ Object

Evaluate a formula



68
69
70
# File 'lib/lxl.rb', line 68

def eval(formula)
  LXL::Parser.eval(formula)
end