Class: VpsbClient::Builders::SystemInfoParser
- Inherits:
-
Object
- Object
- VpsbClient::Builders::SystemInfoParser
show all
- Defined in:
- lib/vpsb_client/builders/system_info_parser.rb
Defined Under Namespace
Classes: NoMatchError
Instance Method Summary
collapse
Constructor Details
Returns a new instance of SystemInfoParser.
6
7
8
|
# File 'lib/vpsb_client/builders/system_info_parser.rb', line 6
def initialize(cmd)
@cmd = cmd
end
|
Instance Method Details
#find_matches(regex) ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'lib/vpsb_client/builders/system_info_parser.rb', line 14
def find_matches(regex)
regex = Regexp.new(regex)
matches = nil
lines.each do |line|
matches = regex.match(line)
break if matches
end
matches
end
|
#find_matches!(regex) ⇒ Object
24
25
26
27
28
|
# File 'lib/vpsb_client/builders/system_info_parser.rb', line 24
def find_matches!(regex)
matches = find_matches(regex)
raise NoMatchError, "Cannot find /#{regex}/" unless matches
matches
end
|
#lines ⇒ Object
10
11
12
|
# File 'lib/vpsb_client/builders/system_info_parser.rb', line 10
def lines
IO.popen(@cmd) { |f| f.readlines }
end
|