Class: LXL::Namespace
Overview
Constants and functions defined here will become available to formulas.
class MyLXLNamespace < LXL::Namespace
NAME = 'John Doe'
def upper(string) string.to_s.upcase end
end
class MyLXL < LXL::Parser
def self.namespace_class() MyLXLNamespace end
end
MyLXL.eval('=UPPER(NAME)')
Constant Summary
collapse
- TRUE =
true
- FALSE =
false
- NULL =
nil
EmptyNamespace::METHODS
Instance Method Summary
collapse
const_defined?, deferred_class, register_deferred, register_symbols
Instance Method Details
#and(a, b) ⇒ Object
578
579
580
|
# File 'lib/lxl.rb', line 578
def and(a,b)
LXL.to_b(a) && LXL.to_b(b)
end
|
#date(y, m, d) ⇒ Object
610
611
612
|
# File 'lib/lxl.rb', line 610
def date(y,m,d)
Date.new(y,m,d).ajd.to_f
end
|
#datetime(string) ⇒ Object
614
615
616
|
# File 'lib/lxl.rb', line 614
def datetime(string)
DateTime.parse(string.to_s).ajd.to_f
end
|
#if(c, a, b) ⇒ Object
590
591
592
|
# File 'lib/lxl.rb', line 590
def if(c,a,b)
LXL.to_b(c) ? a : b
end
|
#in(n, h) ⇒ Object
598
599
600
|
# File 'lib/lxl.rb', line 598
def in(n,h)
h.respond_to?(:include?) ? h.include?(n) : false
end
|
#list(*items) ⇒ Object
594
595
596
|
# File 'lib/lxl.rb', line 594
def list(*items)
items
end
|
#not(c) ⇒ Object
586
587
588
|
# File 'lib/lxl.rb', line 586
def not(c)
! c
end
|
#now ⇒ Object
606
607
608
|
# File 'lib/lxl.rb', line 606
def now
DateTime.now.ajd.to_f
end
|
#or(a, b) ⇒ Object
582
583
584
|
# File 'lib/lxl.rb', line 582
def or(a,b)
LXL.to_b(a) || LXL.to_b(b)
end
|
#time(h, m, s) ⇒ Object
618
619
620
|
# File 'lib/lxl.rb', line 618
def time(h,m,s)
DateTime.valid_time?(h,m,s) ? DateTime.valid_time?(h,m,s).to_f : raise(ArgumentError, 'invalid time')
end
|
#today ⇒ Object
602
603
604
|
# File 'lib/lxl.rb', line 602
def today
Date.today.ajd.to_f
end
|