Class: Erlang::Export
- Inherits:
-
Object
- Object
- Erlang::Export
- Defined in:
- lib/erlang/export.rb
Overview
An Export
is an external function. It corresponds to the fun M:F/A
syntax from Erlang.
Creating Exports
Erlang::Export[:erlang, :make_ref, 0]
# => Erlang::Export[:erlang, :make_ref, 0]
Instance Attribute Summary collapse
-
#arity ⇒ Integer
readonly
Return the arity for this
Export
. -
#function ⇒ Atom
readonly
Return the function for this
Export
. -
#mod ⇒ Atom
readonly
Return the module for this
Export
.
Class Method Summary collapse
-
.[](mod, function, arity) ⇒ Export
Create a new
Export
populated with the givenmod
,function
, andarity
. -
.compare(a, b) ⇒ -1, ...
Compares
a
andb
and returns whether they are less than, equal to, or greater than each other.
Instance Method Summary collapse
-
#eql?(other) ⇒ Boolean
(also: #==)
Return true if
other
has the same type and contents as thisExport
. -
#erlang_inspect(raw = false) ⇒ ::String
Return the contents of this
Export
as a Erlang-readable::String
. -
#inspect ⇒ ::String
The nicely formatted version of the
Export
.
Instance Attribute Details
#arity ⇒ Integer (readonly)
Return the arity for this Export
23 24 25 |
# File 'lib/erlang/export.rb', line 23 def arity @arity end |
#function ⇒ Atom (readonly)
Return the function for this Export
19 20 21 |
# File 'lib/erlang/export.rb', line 19 def function @function end |
#mod ⇒ Atom (readonly)
Return the module for this Export
15 16 17 |
# File 'lib/erlang/export.rb', line 15 def mod @mod end |
Class Method Details
.[](mod, function, arity) ⇒ Export
Create a new Export
populated with the given mod
, function
, and arity
.
32 33 34 |
# File 'lib/erlang/export.rb', line 32 def [](mod, function, arity) return new(mod, function, arity) end |
.compare(a, b) ⇒ -1, ...
Compares a
and b
and returns whether they are less than,
equal to, or greater than each other.
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/erlang/export.rb', line 43 def compare(a, b) raise ArgumentError, "'a' must be of Erlang::Export type" unless a.kind_of?(Erlang::Export) raise ArgumentError, "'b' must be of Erlang::Export type" unless b.kind_of?(Erlang::Export) c = Erlang.compare(a.mod, b.mod) return c if c != 0 c = Erlang.compare(a.function, b.function) return c if c != 0 c = Erlang.compare(a.arity, b.arity) return c end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
Return true if other
has the same type and contents as this Export
.
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/erlang/export.rb', line 67 def eql?(other) return true if other.equal?(self) if instance_of?(other.class) return !!(mod == other.mod && function == other.function && arity == other.arity) else return !!(Erlang.compare(other, self) == 0) end end |
#erlang_inspect(raw = false) ⇒ ::String
Return the contents of this Export
as a Erlang-readable ::String
.
86 87 88 89 90 91 92 93 94 |
# File 'lib/erlang/export.rb', line 86 def erlang_inspect(raw = false) result = 'fun ' result << Erlang.inspect(@mod, raw: raw) result << ':' result << Erlang.inspect(@function, raw: raw) result << '/' result << Erlang.inspect(@arity, raw: raw) return result end |
#inspect ⇒ ::String
Returns the nicely formatted version of the Export
.
97 98 99 |
# File 'lib/erlang/export.rb', line 97 def inspect return "Erlang::Export[#{mod.inspect}, #{function.inspect}, #{arity.inspect}]" end |