Class: Netlink::Addrinfo
- Inherits:
-
Object
- Object
- Netlink::Addrinfo
- Defined in:
- lib/netlink/addrinfo.rb
Overview
AddrInfo for Socket.
Instance Attribute Summary collapse
-
#afamily ⇒ Object
readonly
Returns the value of attribute afamily.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(sockaddr) ⇒ Addrinfo
constructor
A new instance of Addrinfo.
-
#to_sockaddr ⇒ String
(also: #to_s, #to_str)
returns the socket address as packed struct sockaddr string.
Constructor Details
#initialize(sockaddr) ⇒ Addrinfo
Returns a new instance of Addrinfo.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/netlink/addrinfo.rb', line 13 def initialize(sockaddr) case sockaddr when Array init_from_array(sockaddr) when String init_from_string(sockaddr) else raise TypeError, 'sockaddr must be a String or an Array' end end |
Instance Attribute Details
#afamily ⇒ Object (readonly)
Returns the value of attribute afamily.
9 10 11 |
# File 'lib/netlink/addrinfo.rb', line 9 def afamily @afamily end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
9 10 11 |
# File 'lib/netlink/addrinfo.rb', line 9 def groups @groups end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
9 10 11 |
# File 'lib/netlink/addrinfo.rb', line 9 def pid @pid end |
Instance Method Details
#==(other) ⇒ Object
32 33 34 |
# File 'lib/netlink/addrinfo.rb', line 32 def ==(other) other.is_a?(Addrinfo) && (other.pid == @pid) && (other.groups == @groups) end |
#to_sockaddr ⇒ String Also known as: to_s, to_str
returns the socket address as packed struct sockaddr string
26 27 28 |
# File 'lib/netlink/addrinfo.rb', line 26 def to_sockaddr Socket.sockaddr_nl(@pid, @groups) end |