Class: Nl::Raw::Client
- Inherits:
-
Object
- Object
- Nl::Raw::Client
- Defined in:
- nl/lib/nl/raw/client.rb
Overview
Owns one raw Netlink connection shared by compatible families.
Class Method Summary collapse
-
.open(protonum:, executor: nil, notification_capacity: Nl::Connection::DEFAULT_NOTIFICATION_CAPACITY) ⇒ Object
Opens a client for a raw Netlink protocol.
Instance Method Summary collapse
-
#close ⇒ void
Closes the underlying Netlink connection.
-
#family(family_class) ⇒ Family
Builds a family backed by this client's connection.
-
#initialize(protonum:, executor: nil, notification_capacity: Nl::Connection::DEFAULT_NOTIFICATION_CAPACITY) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(protonum:, executor: nil, notification_capacity: Nl::Connection::DEFAULT_NOTIFICATION_CAPACITY) ⇒ Client
Returns a new instance of Client.
43 44 45 46 47 48 49 50 |
# File 'nl/lib/nl/raw/client.rb', line 43 def initialize(protonum:, executor: nil, notification_capacity: Nl::Connection::DEFAULT_NOTIFICATION_CAPACITY) @protonum = protonum @connection = Nl::Connection.new( protocol: Protocol.new(protonum), executor:, notification_capacity:, ) end |
Class Method Details
.open(protonum:, executor: nil, notification_capacity: Nl::Connection::DEFAULT_NOTIFICATION_CAPACITY) ⇒ Client .open(protonum:, executor: nil, notification_capacity: Nl::Connection::DEFAULT_NOTIFICATION_CAPACITY) {|client| ... } ⇒ Object
Opens a client for a raw Netlink protocol.
28 29 30 31 32 33 34 35 36 37 |
# File 'nl/lib/nl/raw/client.rb', line 28 def self.open(protonum:, executor: nil, notification_capacity: Nl::Connection::DEFAULT_NOTIFICATION_CAPACITY) client = new(protonum:, executor:, notification_capacity:) return client unless block_given? begin yield client ensure client.close end end |
Instance Method Details
#close ⇒ void
This method returns an undefined value.
Closes the underlying Netlink connection.
78 79 80 |
# File 'nl/lib/nl/raw/client.rb', line 78 def close @connection.close end |
#family(family_class) ⇒ Family
Builds a family backed by this client's connection.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'nl/lib/nl/raw/client.rb', line 59 def family(family_class) unless family_class <= Family raise TypeError, "family class must inherit from #{Family}" end unless family_class::PROTONUM == @protonum raise ArgumentError, "family protonum #{family_class::PROTONUM} does not match client protonum #{@protonum}" end family_class.new( @connection, endpoint: Endpoint.new(family_class), ) end |