class WAB::Impl::ExprParser
Constants
- XMAP
Public Class Methods
parse(native)
click to toggle source
Parses an Array into a set of Expr
subsclasses.
- native
-
native Ruby representation of the expression.
# File lib/wab/impl/expr_parser.rb, line 24 def parse(native) raise WAB::TypeError.new('Invalid expression. Must be an Array.') unless native.is_a?(Array) op = native[0] op = op.downcase.to_sym unless op.is_a?(Symbol) xclass = XMAP[op] raise WAB::Error.new("#{op} is not a valid expression function.") if xclass.nil? args = [] native[1..-1].each { |n| args << if n.is_a?(Array) parse(n) elsif n.is_a?(String) unless n.empty? if "'" == n[0] n[1..-1] else WAB::Impl::Data.detect_string(n) end end else n end } xclass.new(*args) end