Parent

Class Index [+]

Quicksearch

MessagePack::RPC::Address

Public Class Methods

load(raw) click to toggle source
     # File lib/msgpack/rpc/address.rb, line 101
101:         def self.load(raw)
102:                 Address.new *parse(raw)
103:         end
new(host, port) click to toggle source

Linux

    # File lib/msgpack/rpc/address.rb, line 39
39:                 def initialize(host, port)
40:                         raw = Socket.pack_sockaddr_in(port, host)
41:                         family = raw.unpack('S')[0]
42:                         if family == Socket::AF_INET
43:                                 @serial = raw[2,6]
44:                         elsif family == Socket::AF_INET6
45:                                 @serial = raw[2,2] + raw[8,16]
46:                         else
47:                                 raise "Unknown address family: #{family}"
48:                         end
49:                 end
new(host, port) click to toggle source

BSD

    # File lib/msgpack/rpc/address.rb, line 52
52:                 def initialize(host, port)
53:                         raw = Socket.pack_sockaddr_in(port, host)
54:                         family = raw.unpack('CC')[1]
55:                         if family == Socket::AF_INET
56:                                 @serial = raw[2,6]
57:                         elsif family == Socket::AF_INET6
58:                                 @serial = raw[2,2] + raw[8,16]
59:                         else
60:                                 raise "Unknown address family: #{family}"
61:                         end
62:                 end
parse(raw) click to toggle source
    # File lib/msgpack/rpc/address.rb, line 97
97:         def self.parse(raw)
98:                 Socket.unpack_sockaddr_in(parse_sockaddr(raw)).reverse
99:         end
parse_sockaddr(raw) click to toggle source
    # File lib/msgpack/rpc/address.rb, line 85
85:         def self.parse_sockaddr(raw)
86:                 if raw.length == 6
87:                         addr = Socket.pack_sockaddr_in(0, '0.0.0.0')
88:                         addr[2,6] = raw[0,6]
89:                 else
90:                         addr = Socket.pack_sockaddr_in(0, '::')
91:                         addr[2,2]  = raw[0,2]
92:                         addr[8,16] = raw[2,16]
93:                 end
94:                 addr
95:         end

Public Instance Methods

<=>(o) click to toggle source
     # File lib/msgpack/rpc/address.rb, line 121
121:         def <=>(o)
122:                 dump <=> o.dump
123:         end
==(o) click to toggle source
     # File lib/msgpack/rpc/address.rb, line 137
137:         def ==(o)
138:                 eql?(o)
139:         end
connectable?() click to toggle source
    # File lib/msgpack/rpc/address.rb, line 73
73:         def connectable?
74:                 port != 0
75:         end
dump() click to toggle source
     # File lib/msgpack/rpc/address.rb, line 105
105:         def dump
106:                 @serial
107:         end
eql?(o) click to toggle source
     # File lib/msgpack/rpc/address.rb, line 129
129:         def eql?(o)
130:                 o.class == Address && dump.eql?(o.dump)
131:         end
hash() click to toggle source
     # File lib/msgpack/rpc/address.rb, line 133
133:         def hash
134:                 dump.hash
135:         end
host() click to toggle source
    # File lib/msgpack/rpc/address.rb, line 65
65:         def host
66:                 unpack[0]
67:         end
inspect() click to toggle source
     # File lib/msgpack/rpc/address.rb, line 125
125:         def inspect
126:                 "#<#{self.class} #{to_s} @serial=#{@serial.inspect}>"
127:         end
port() click to toggle source
    # File lib/msgpack/rpc/address.rb, line 69
69:         def port
70:                 unpack[1]
71:         end
sockaddr() click to toggle source
    # File lib/msgpack/rpc/address.rb, line 77
77:         def sockaddr
78:                 Address.parse_sockaddr(@serial)
79:         end
to_a() click to toggle source
     # File lib/msgpack/rpc/address.rb, line 117
117:         def to_a
118:                 unpack
119:         end
to_msgpack(out = '') click to toggle source
     # File lib/msgpack/rpc/address.rb, line 109
109:         def to_msgpack(out = '')
110:                 @serial.to_msgpack(out)
111:         end
to_s() click to toggle source
     # File lib/msgpack/rpc/address.rb, line 113
113:         def to_s
114:                 unpack.join(':')
115:         end
unpack() click to toggle source
    # File lib/msgpack/rpc/address.rb, line 81
81:         def unpack
82:                 Address.parse(@serial)
83:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.