Class: SNMP::Open::Parser::ValueParser

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/snmp/open/parser/value_parser.rb

Overview

base class for value parsers

Defined Under Namespace

Classes: Bits, Default, HexString, Integer, NoSuchInstance, NoSuchObject, Other, Stop, Timeticks

Constant Summary collapse

KNOWN_TOKENS =

class NoSuchObject < ValueParser

{
  NOSUCHINSTANCE_STR => NoSuchInstance,
  NOSUCHOBJECT_STR =>  NoSuchObject,
  NOMOREVARIABLES_STR => Stop
}.freeze
KNOWN_TYPES =
{
  nil => Default,
  'BITS' => Bits,
  'INTEGER'   => ValueParser::Integer,
  'Gauge32'   => ValueParser::Integer,
  'Gauge64'   => ValueParser::Integer,
  'Counter32' => ValueParser::Integer,
  'Counter64' => ValueParser::Integer,
  'Hex-STRING' => HexString,
  'Timeticks' => Timeticks
}.freeze

Constants included from Constants

Constants::NOMOREVARIABLES_STR, Constants::NOSUCHINSTANCE_STR, Constants::NOSUCHOBJECT_STR

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, token) ⇒ ValueParser

Returns a new instance of ValueParser.



13
14
15
16
# File 'lib/snmp/open/parser/value_parser.rb', line 13

def initialize(type, token)
  @type = type
  @token = token
end

Class Method Details

.find(type, token) ⇒ Object



8
9
10
11
# File 'lib/snmp/open/parser/value_parser.rb', line 8

def self.find(type, token)
  cls = KNOWN_TOKENS[token] || KNOWN_TYPES[type] || Other
  cls.new(type, token)
end

Instance Method Details

#parseObject



18
19
20
# File 'lib/snmp/open/parser/value_parser.rb', line 18

def parse(*)
  @parse
end