Class: Rethtool::DriverSettings
- Inherits:
-
Object
- Object
- Rethtool::DriverSettings
- Defined in:
- lib/rethtool/driver_settings.rb
Overview
Driver settings of a network interface.
Create an instance of this class with the interface name as the only parameter, then use the available instance methods to get the info you seek:
if = Rethtool::DriverSettings.new("eth0")
puts "Bus info is #{if.bus_info}"
Instance Method Summary collapse
- #as_str(str) ⇒ Object
-
#bus_info ⇒ Object
Returns a string with the bus information of the interface.
-
#driver ⇒ Object
Returns a string with the value of the interface driver (kernel module).
-
#initialize(interface) ⇒ DriverSettings
constructor
Create a new DriverSettings object.
Constructor Details
#initialize(interface) ⇒ DriverSettings
Create a new DriverSettings object. Simply pass it the name of the interface you want to get the settings for.
17 18 19 20 21 |
# File 'lib/rethtool/driver_settings.rb', line 17 def initialize(interface) cmd_driver = Rethtool::EthtoolCmdDriver.new cmd_driver.cmd = Rethtool::ETHTOOL_CMD_GDRVINFO @driver_data = Rethtool.ioctl(interface, cmd_driver) end |
Instance Method Details
#as_str(str) ⇒ Object
33 34 35 |
# File 'lib/rethtool/driver_settings.rb', line 33 def as_str(str) str.pack('c*').delete("\000") end |
#bus_info ⇒ Object
Returns a string with the bus information of the interface.
29 30 31 |
# File 'lib/rethtool/driver_settings.rb', line 29 def bus_info as_str(@driver_data.bus_info) end |
#driver ⇒ Object
Returns a string with the value of the interface driver (kernel module).
24 25 26 |
# File 'lib/rethtool/driver_settings.rb', line 24 def driver as_str(@driver_data.driver) end |