<commit_before>.. -*- rst -*-

.. groonga-command
.. database: commands_ruby_eval

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

Summary
-------

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

Syntax
------

This command takes only one required parameter::

  ruby_eval script

Usage
-----

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

Here is an example that just calculate ``1 + 2`` as Ruby script.

.. groonga-command
.. include:: ../../example/reference/commands/ruby_eval/calc.log
.. plugin_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.

``script``
""""""""""

Specifies the Ruby script which you want to evaluate.

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

``ruby_eval`` returns the evaluated result with metadata such as
exception information (Including metadata isn't implemented yet)::

  [HEADER, {"value": EVALUATED_VALUE}]

``HEADER``

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

``EVALUATED_VALUE``

  ``EVALUATED_VALUE`` is the evaludated value of ``ruby_script``.

  ``ruby_eval`` supports only a number for evaluated value for now.
  Supported types will be increased in the future.

See also
--------
<commit_msg>doc ruby_eval: fix a typo (#1317)<commit_after>.. -*- rst -*-

.. groonga-command
.. database: commands_ruby_eval

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

Summary
-------

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

Syntax
------

This command takes only one required parameter::

  ruby_eval script

Usage
-----

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

Here is an example that just calculate ``1 + 2`` as Ruby script.

.. groonga-command
.. include:: ../../example/reference/commands/ruby_eval/calc.log
.. plugin_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.

``script``
""""""""""

Specifies the Ruby script which you want to evaluate.

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

``ruby_eval`` returns the evaluated result with metadata such as
exception information (Including metadata isn't implemented yet)::

  [HEADER, {"value": EVALUATED_VALUE}]

``HEADER``

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

``EVALUATED_VALUE``

  ``EVALUATED_VALUE`` is the evaluated value of ``ruby_script``.

  ``ruby_eval`` supports only a number for evaluated value for now.
  Supported types will be increased in the future.

See also
--------

{'fraction_non_alphanumeric': 0.1483036026582721, 'fraction_numerical': 0.004197271773347324, 'mean_word_length': 3.627831715210356, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '966516', 'n_tokens_mistral': 859, 'n_tokens_neox': 795, 'n_words': 315}