Class: Lspci::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/lspci/parser.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_resultObject (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_outputObject



15
16
17
# File 'lib/lspci/parser.rb', line 15

def lspci_output
  @lspci_output ||= `lspci -vmm`
end

#parseObject



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