Module: NETSNMP::OID

Defined in:
lib/netsnmp/oid.rb

Overview

Abstracts the OID structure

Constant Summary collapse

OIDREGEX =
/^[\d.]*$/.freeze

Class Method Summary collapse

Class Method Details

.build(id) ⇒ Object

Raises:



13
14
15
16
17
18
19
20
# File 'lib/netsnmp/oid.rb', line 13

def build(id)
  oid = MIB.oid(id)

  raise Error, "no OID found for #{id}" unless oid

  oid = oid.delete_prefix(".") if oid.start_with?(".")
  oid
end

.parent?(parent_oid, child_oid) ⇒ true, false

Returns whether the given OID belongs to the sub-tree.

Parameters:

  • child (OID, String)

    oid another oid

Returns:

  • (true, false)

    whether the given OID belongs to the sub-tree



29
30
31
# File 'lib/netsnmp/oid.rb', line 29

def parent?(parent_oid, child_oid)
  child_oid.match?(/\A#{parent_oid}\./)
end

.to_asn(oid) ⇒ Object



22
23
24
# File 'lib/netsnmp/oid.rb', line 22

def to_asn(oid)
  OpenSSL::ASN1::ObjectId.new(oid)
end