.. -*- rst -*-

.. highlightlang:: none

.. groonga-command
.. database: commands_ruby_eval

``ruby_eval``
=============

Summary
-------

``ruby_eval`` command evaluates ruby script and returns the result.

Syntax
------

``ruby_eval`` has one required parameter::

  ruby_eval ruby_script

Usage
-----

You can execute any scripts which mruby supports by calling ``ruby_eval``.

Here is an example that just calculate ``1 + 2`` by mruby plugin.

.. groonga-command
.. include:: ../../example/reference/commands/ruby_eval/calc.log
.. register ruby/eval
.. ruby_eval "1 + 2"

Register ``ruby/eval`` plugin to use ``ruby_eval`` command in advance.

Note that ``ruby_eval`` is implemented as an experimental plugin,
and the specification may be changed in the future.

Parameters
----------

This section describes all parameters.

``ruby_script``
"""""""""""""""

It specifies the ruby script which you want to evaluate.

Return value
------------

``ruby_eval`` returns the evaluated result which key is "value" as json format::

  [[HEADER, EVALUATED]]

``HEADER``

  See :doc:`/reference/command/output_format` about ``HEADER``.

``EVALUATED``

  ``EVALUATED`` consists of pair of key and value in forms of {key:value}.

  .. list-table::
     :header-rows: 1

     * - Name
       - Description
     * - ``key``
       - reserved word 'value'.
     * - ``value``
       - the value of evaluated script. It must be a number.

See also
--------

