Class: Erlang::Port
- Inherits:
-
Object
- Object
- Erlang::Port
- Defined in:
- lib/erlang/port.rb
Overview
A Port
is a port object obtained from erlang:open_port/2
.
Creating Ports
Erlang::Port["nonode@nohost", 100, 1]
# => Erlang::Port[:"nonode@nohost", 100, 1]
Instance Attribute Summary collapse
-
#creation ⇒ Integer
readonly
Return the creation for this
Port
. -
#id ⇒ Integer
readonly
Return the id for this
Port
. -
#node ⇒ Atom
readonly
Return the node for this
Port
.
Class Method Summary collapse
-
.[](node, id, creation = 0) ⇒ Port
Create a new
Port
populated with the givennode
,id
, andcreation
. -
.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 thisPort
. -
#erlang_inspect(raw = false) ⇒ ::String
Return the contents of this
Port
as a Erlang-readable::String
. -
#inspect ⇒ ::String
The nicely formatted version of the
Port
.
Instance Attribute Details
#creation ⇒ Integer (readonly)
Return the creation for this Port
23 24 25 |
# File 'lib/erlang/port.rb', line 23 def creation @creation end |
#id ⇒ Integer (readonly)
Return the id for this Port
19 20 21 |
# File 'lib/erlang/port.rb', line 19 def id @id end |
#node ⇒ Atom (readonly)
Return the node for this Port
15 16 17 |
# File 'lib/erlang/port.rb', line 15 def node @node end |
Class Method Details
.[](node, id, creation = 0) ⇒ Port
Create a new Port
populated with the given node
, id
, and creation
.
32 33 34 |
# File 'lib/erlang/port.rb', line 32 def [](node, id, creation = 0) return new(node, id, creation) 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/port.rb', line 43 def compare(a, b) raise ArgumentError, "'a' must be of Erlang::Port type" unless a.kind_of?(Erlang::Port) raise ArgumentError, "'b' must be of Erlang::Port type" unless b.kind_of?(Erlang::Port) c = Erlang.compare(a.node, b.node) return c if c != 0 c = Erlang.compare(a.id, b.id) return c if c != 0 c = Erlang.compare(a.creation, b.creation) return c end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
Return true if other
has the same type and contents as this Port
.
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/erlang/port.rb', line 74 def eql?(other) return true if other.equal?(self) if instance_of?(other.class) return !!(node == other.node && id == other.id && creation == other.creation) else return !!(Erlang.compare(other, self) == 0) end end |
#erlang_inspect(raw = false) ⇒ ::String
Return the contents of this Port
as a Erlang-readable ::String
.
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/erlang/port.rb', line 93 def erlang_inspect(raw = false) if raw == true and Erlang.respond_to?(:term_to_binary) result = 'erlang:binary_to_term(' result << Erlang.inspect(Erlang.term_to_binary(self), raw: raw) result << ')' return result else return Erlang.inspect(Erlang::Tuple[:port, node, id, creation], raw: raw) end end |
#inspect ⇒ ::String
Returns the nicely formatted version of the Port
.
105 106 107 |
# File 'lib/erlang/port.rb', line 105 def inspect return "Erlang::Port[#{node.inspect}, #{id.inspect}, #{creation.inspect}]" end |