export v0.1.1 Export.Ruby
Wrapper for ruby.
Example
defmodule SomeRubyCall do
use Export.Ruby
def call_ruby_method
# path to ruby files
{:ok, ruby} = Ruby.start(ruby_lib: Path.expand("lib/ruby"))
# call "upcase" method from "test" file with "hello" argument
ruby |> Ruby.call("test", "upcase", ["hello"])
# same as above but prettier
ruby |> Ruby.call(upcase("hello"), from_file: "test")
end
end
Summary
Functions
Call Ruby function
Start Ruby instance with the default options
Start Ruby instance with options.
The options
argument should be a map with the following options
Start Ruby instance with name and options.
The instance will be registered with name. The options
argument should be a map with the following options
The same as start/0 except the link to the current process is also created
The same as start/1 except the link to the current process is also created
The same as start/2 except the link to the current process is also created
Stop Ruby instance
Macros
Call Ruby function
Functions
Call Ruby function.
Parameters
- instance: pid witch is returned by one of the
start
function - file: file to run ruby function from
- function: name of the function
- arguments: arguments to pass to the function
Example
# call "upcase" method from "test" file with "hello" argument
ruby |> Ruby.call("test", "upcase", ["hello"])
Start Ruby instance with the default options.
Returns {:ok, pid}
.
Examples
iex> Export.Ruby.start()
{:ok, pid}
Start Ruby instance with options.
The options
argument should be a map with the following options.
Ruby options
- ruby: Path to the Ruby interpreter executable
- ruby_lib: The Ruby programs search path. The Path variable can be a string in RUBYLIB format or a list of paths.
Start Ruby instance with name and options.
The instance will be registered with name. The options
argument should be a map with the following options.
Ruby options
- ruby: Path to the Ruby interpreter executable
- ruby_lib: The Ruby programs search path. The Path variable can be a string in RUBYLIB format or a list of paths.
The same as start/2 except the link to the current process is also created.
Macros
Call Ruby function.
Parameters
- instance: pid witch is returned by one of the
start
function - expression: function expression to execute in ruby world
- from_file: file to run ruby function from
Example
# call "upcase" method from "test" file with "hello" argument
ruby |> Ruby.call(upcase("hello"), from_file: "test")