| 1 |
.. -*- rst -*- |
| 2 |
|
| 3 |
.. groonga-command |
| 4 |
.. database: commands_ruby_eval |
| 5 |
|
| 6 |
``ruby_eval`` |
| 7 |
============= |
| 8 |
|
| 9 |
Summary |
| 10 |
------- |
| 11 |
|
| 12 |
``ruby_eval`` command evaluates Ruby script and returns the result. |
| 13 |
|
| 14 |
Syntax |
| 15 |
------ |
| 16 |
|
| 17 |
This command takes only one required parameter:: |
| 18 |
|
| 19 |
ruby_eval script |
| 20 |
|
| 21 |
Usage |
| 22 |
----- |
| 23 |
|
| 24 |
You can execute any scripts which mruby supports by calling ``ruby_eval``. |
| 25 |
|
| 26 |
Here is an example that just calculate ``1 + 2`` as Ruby script. |
| 27 |
|
| 28 |
.. groonga-command |
| 29 |
.. include:: ../../example/reference/commands/ruby_eval/calc.log |
| 30 |
.. plugin_register ruby/eval |
| 31 |
.. ruby_eval "1 + 2" |
| 32 |
|
| 33 |
Register ``ruby/eval`` plugin to use ``ruby_eval`` command in advance. |
| 34 |
|
| 35 |
Note that ``ruby_eval`` is implemented as an experimental plugin, |
| 36 |
and the specification may be changed in the future. |
| 37 |
|
| 38 |
Parameters |
| 39 |
---------- |
| 40 |
|
| 41 |
This section describes all parameters. |
| 42 |
|
| 43 |
``script`` |
| 44 |
"""""""""" |
| 45 |
|
| 46 |
Specifies the Ruby script which you want to evaluate. |
| 47 |
|
| 48 |
Return value |
| 49 |
------------ |
| 50 |
|
| 51 |
``ruby_eval`` returns the evaluated result with metadata such as |
| 52 |
exception information (Including metadata isn't implemented yet):: |
| 53 |
|
| 54 |
[HEADER, {"value": EVALUATED_VALUE}] |
| 55 |
|
| 56 |
``HEADER`` |
| 57 |
|
| 58 |
See :doc:`/reference/command/output_format` about ``HEADER``. |
| 59 |
|
| 60 |
``EVALUATED_VALUE`` |
| 61 |
|
| 62 |
``EVALUATED_VALUE`` is the evaluated value of ``ruby_script``. |
| 63 |
|
| 64 |
``ruby_eval`` supports only a number for evaluated value for now. |
| 65 |
Supported types will be increased in the future. |
| 66 |
|
| 67 |
See also |
| 68 |
-------- |
| 69 |
|