Module: Pione::Util::Evaluatable
- Included in:
- Pione
- Defined in:
- lib/pione/util/evaluatable.rb
Overview
Evaluatable is a module for providing to ability to evaluate PIONE expression string.
Instance Method Summary collapse
-
#val(str, domain_dump = nil) ⇒ String
Evaluate the string as a PIONE expression and get the result value as a textized string.
-
#val!(str, domain_dump = nil) ⇒ Object
Evaluate the string as a PIONE expression and get the result value as model object.
Instance Method Details
#val(str, domain_dump = nil) ⇒ String
Evaluate the string as a PIONE expression and get the result value as a textized string.
30 31 32 33 |
# File 'lib/pione/util/evaluatable.rb', line 30 def val(str, domain_dump=nil) env = domain_dump ? domain_dump.env : Lang::Environment.new val!(str, domain_dump).call_pione_method(env, "textize", []).first.value end |
#val!(str, domain_dump = nil) ⇒ Object
Evaluate the string as a PIONE expression and get the result value as model object.
14 15 16 17 18 19 20 |
# File 'lib/pione/util/evaluatable.rb', line 14 def val!(str, domain_dump=nil) env = domain_dump ? domain_dump.env : Lang::Environment.new option = {package_name: env.current_package_id, filename: "pione-eval"} Lang::DocumentTransformer.new.apply( Lang::DocumentParser.new.expr.parse(str), option ).eval(env) end |