Class: LXL::Namespace

Inherits:
EmptyNamespace show all
Defined in:
lib/lxl.rb

Overview

Constants and functions defined here will become available to formulas.

class MyLXLNamespace < LXL::Namespace
  NAME = 'John Doe'
  def upper(text) text.to_s.upcase end
end

class MyLXL < LXL::Parser
  def self.namespace_class() MyLXLNamespace end
end

MyLXL.eval('=UPPER(NAME)')
# => JOHN DOE

Constant Summary collapse

TRUE =
true
FALSE =
false
NULL =
nil

Constants inherited from EmptyNamespace

EmptyNamespace::METHODS

Instance Method Summary collapse

Methods inherited from EmptyNamespace

const_defined?, deferred_class, register_deferred, register_symbols

Instance Method Details

#and(a, b) ⇒ Object



517
518
519
# File 'lib/lxl.rb', line 517

def and(a,b)
  LXL.to_b(a) && LXL.to_b(b)
end

#date(y, m, d) ⇒ Object



549
550
551
# File 'lib/lxl.rb', line 549

def date(y,m,d)
  Date.new(y,m,d).ajd.to_f
end

#datetime(text) ⇒ Object



553
554
555
# File 'lib/lxl.rb', line 553

def datetime(text)
  DateTime.parse(text.to_s).ajd.to_f
end

#if(c, a, b) ⇒ Object



529
530
531
# File 'lib/lxl.rb', line 529

def if(c,a,b)
  LXL.to_b(c) ? a : b
end

#in(n, h) ⇒ Object



537
538
539
# File 'lib/lxl.rb', line 537

def in(n,h)
  h.respond_to?(:include?) ? h.include?(n) : false
end

#list(*items) ⇒ Object



533
534
535
# File 'lib/lxl.rb', line 533

def list(*items)
  items
end

#not(c) ⇒ Object



525
526
527
# File 'lib/lxl.rb', line 525

def not(c)
  ! c
end

#nowObject



545
546
547
# File 'lib/lxl.rb', line 545

def now
  DateTime.now.ajd.to_f
end

#or(a, b) ⇒ Object



521
522
523
# File 'lib/lxl.rb', line 521

def or(a,b)
  LXL.to_b(a) || LXL.to_b(b)
end

#time(h, m, s) ⇒ Object



557
558
559
# File 'lib/lxl.rb', line 557

def time(h,m,s)
  DateTime.valid_time?(h,m,s) ? DateTime.valid_time?(h,m,s).to_f : raise(ArgumentError, 'invalid time')
end

#todayObject



541
542
543
# File 'lib/lxl.rb', line 541

def today
  Date.today.ajd.to_f
end