Class: SNMP::Open::Parser
- Inherits:
-
Object
- Object
- SNMP::Open::Parser
- Defined in:
- lib/snmp/open/parser.rb
Overview
convert SNMP command output into arrays
Defined Under Namespace
Modules: Conversions
Constant Summary collapse
- NOSUCHOBJECT_STR =
'No Such Object available on this agent at this OID'.freeze
- NOSUCHINSTANCE_STR =
'No Such Instance currently exists at this OID'.freeze
Instance Method Summary collapse
-
#initialize(oids) ⇒ Parser
constructor
A new instance of Parser.
- #parse(texts) ⇒ Object
Constructor Details
#initialize(oids) ⇒ Parser
Returns a new instance of Parser.
19 20 21 |
# File 'lib/snmp/open/parser.rb', line 19 def initialize(oids) @oids = oids end |
Instance Method Details
#parse(texts) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/snmp/open/parser.rb', line 23 def parse(texts) columns = texts.map do |text| tokenized = text .gsub(NOSUCHOBJECT_STR, %("#{NOSUCHOBJECT_STR}")) .gsub(NOSUCHINSTANCE_STR, %("#{NOSUCHINSTANCE_STR}")) .shellsplit parse_tokens(tokenized) end table(columns) end |