Erlang::Terms

Build Status

Includes simple classes that represent Erlang's export, list, pid, string, tuple, and map.

Installation

Add this line to your application's Gemfile:

gem 'erlang-terms', require: 'erlang/terms'

And then execute:

$ bundle

Or install it yourself as:

$ gem install erlang-terms

Usage

The following classes show the Erlang representation followed by the corresponding Ruby representation.

See erlang-etf for more information.

Erlang::Export

Module   = erlang,
Function = now,
Arity    = 0,
Export   = fun Module:Function/Arity.
export = Erlang::Export.new(:erlang, :now, 0)
# => #<Erlang::Export fun erlang:now/0>

Erlang::List

Improper List
List = [a | b].
list = Erlang::List[:a].tail(:b)
# => #<Erlang::List [:a | :b]">
list.improper?
# => true
Proper List
List = [a, b].
list = Erlang::List[:a, :b]
# => #<Erlang::List [:a, :b | []]">
list.improper?
# => false

Erlang::Map

Map = #{atom => 1}.
map = Erlang::Map[:atom, 1]
# => #<Erlang::Map #{:atom => 1}>

Erlang::Nil

Nil = [].
erlang_nil = Erlang::Nil.new
# => #<Erlang::Nil []>

Erlang::Pid

Pid = self().

%% or

Id     = 100,
Serial = 5,
Pid    = pid(0, Id, Serial).

%% or

Pid = list_to_pid("<0.100.5>").
pid = Erlang::Pid.new('node@host', 100, 5, 0)
# => #<Erlang::Pid <0.100.5> @node="node@host" @creation=0>

Erlang::String

String = "test".
string = Erlang::String.new("test")
# => #<Erlang::String "test">

Erlang::Tuple

Tuple = {atom, 1}.
tuple = Erlang::Tuple[:atom, 1]
# => #<Erlang::Tuple {:atom, 1}>

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request