Class: SNMP::Open::Parser
- Inherits:
-
Object
- Object
- SNMP::Open::Parser
- Includes:
- Constants
- Defined in:
- lib/snmp/open/parser.rb,
lib/snmp/open/parser/constants.rb,
lib/snmp/open/parser/value_parser.rb
Overview
convert SNMP command output into arrays
Defined Under Namespace
Modules: Constants, Static Classes: ValueParser
Constant Summary
Constants included from Constants
Constants::NOMOREVARIABLES_STR, Constants::NOSUCHINSTANCE_STR, Constants::NOSUCHOBJECT_STR
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.
18 19 20 |
# File 'lib/snmp/open/parser.rb', line 18 def initialize(oids) @oids = oids end |
Instance Method Details
#parse(texts) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/snmp/open/parser.rb', line 22 def parse(texts) columns = texts.map do |text| tokenized = text .gsub(/^([0-9\.]+) = (Opaque|STRING): ((?!")[^\n]*)\n/, %(\\1 = \\2: "\\3"\n)) .gsub(Static::ANY_MESSAGE, Static::QUOTED_MESSAGES) .shellsplit parse_tokens(tokenized) end table(columns) end |