Class: Gloo::Verbs::Eval
- Inherits:
-
Core::Verb
- Object
- Core::Baseo
- Core::Verb
- Gloo::Verbs::Eval
- Defined in:
- lib/gloo/verbs/eval.rb
Constant Summary collapse
- KEYWORD =
'eval'.freeze
- KEYWORD_SHORT =
'noop'.freeze
Constants inherited from Core::Baseo
Core::Baseo::NOT_IMPLEMENTED_ERR
Instance Attribute Summary
Attributes inherited from Core::Verb
Attributes inherited from Core::Baseo
Class Method Summary collapse
-
.doc_data ⇒ Object
Get the verb's documentation data.
-
.keyword ⇒ Object
Get the Verb's keyword.
-
.keyword_shortcut ⇒ Object
Get the Verb's keyword shortcut.
Instance Method Summary collapse
-
#run ⇒ Object
Run the verb.
Methods inherited from Core::Verb
#display_value, help, inherited, #initialize, #type_display
Methods inherited from Core::Baseo
Constructor Details
This class inherits a constructor from Gloo::Core::Verb
Class Method Details
.doc_data ⇒ Object
Get the verb's documentation data.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/gloo/verbs/eval.rb', line 48 def self.doc_data { :name => KEYWORD, :shortcut => KEYWORD_SHORT, :description => 'Evaluate an expression and put the result into it.', :syntax => [ 'eval {expression}' ], :parameters => [ '{expression} — The expression that will be evaluated. The expression is optional. If not provided, eval will result in true.' ], :result => 'The result of the expression evaluation is put ' \ 'into it. No other action is performed.', :examples => <<~EXAMPLES.strip > eval "me" > eval "hello " "world" > eval 132 * 23 > eval path.to.num = 1 EXAMPLES } end |
.keyword ⇒ Object
Get the Verb's keyword.
17 18 19 |
# File 'lib/gloo/verbs/eval.rb', line 17 def self.keyword return KEYWORD end |
.keyword_shortcut ⇒ Object
Get the Verb's keyword shortcut.
24 25 26 |
# File 'lib/gloo/verbs/eval.rb', line 24 def self.keyword_shortcut return KEYWORD_SHORT end |
Instance Method Details
#run ⇒ Object
Run the verb.
31 32 33 34 35 36 37 38 39 |
# File 'lib/gloo/verbs/eval.rb', line 31 def run if @tokens.token_count > 1 expr = Gloo::Expr::Expression.new( @engine, @tokens.params ) result = expr.evaluate @engine.heap.it.set_to result else @engine.heap.it.set_to true end end |