Class: Lspci::Parser
- Inherits:
-
Object
- Object
- Lspci::Parser
- Defined in:
- lib/lspci/parser.rb
Instance Attribute Summary collapse
-
#command_result ⇒ Object
readonly
Returns the value of attribute command_result.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(command_result = nil) ⇒ Parser
constructor
A new instance of Parser.
- #lspci_output ⇒ Object
- #parse ⇒ Object
Constructor Details
#initialize(command_result = nil) ⇒ Parser
Returns a new instance of Parser.
11 12 13 |
# File 'lib/lspci/parser.rb', line 11 def initialize(command_result=nil) @command_result = command_result end |
Instance Attribute Details
#command_result ⇒ Object (readonly)
Returns the value of attribute command_result.
5 6 7 |
# File 'lib/lspci/parser.rb', line 5 def command_result @command_result end |
Class Method Details
.parse(command_result = nil) ⇒ Object
7 8 9 |
# File 'lib/lspci/parser.rb', line 7 def self.parse(command_result=nil) new(command_result).parse end |
Instance Method Details
#lspci_output ⇒ Object
15 16 17 |
# File 'lib/lspci/parser.rb', line 15 def lspci_output @lspci_output ||= `lspci -vmm` end |
#parse ⇒ Object
19 20 21 22 23 24 |
# File 'lib/lspci/parser.rb', line 19 def parse command_result = (self.command_result || lspci_output) split_devices = split_devices(command_result) split_devices.map { |device| parse_device(device) } end |