Module: NETSNMP::OID
- Defined in:
- lib/netsnmp/oid.rb
Overview
Abstracts the OID structure
Constant Summary collapse
- OIDREGEX =
/^[\d\.]*$/
Class Method Summary collapse
- .build(o) ⇒ Object
-
.parent?(parent_oid, child_oid) ⇒ true, false
Whether the given OID belongs to the sub-tree.
- .to_asn(oid) ⇒ Object
Class Method Details
.build(o) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/netsnmp/oid.rb', line 11 def build(o) case o when OID then o when Array o.join(".") when OIDREGEX o = o[1..-1] if o.start_with?(".") o # TODO: MIB to OID else raise Error, "can't convert #{o} to OID" end end |
.parent?(parent_oid, child_oid) ⇒ true, false
Returns whether the given OID belongs to the sub-tree.
31 32 33 |
# File 'lib/netsnmp/oid.rb', line 31 def parent?(parent_oid, child_oid) child_oid.match(/\A#{parent_oid}\./) end |
.to_asn(oid) ⇒ Object
24 25 26 |
# File 'lib/netsnmp/oid.rb', line 24 def to_asn(oid) OpenSSL::ASN1::ObjectId.new(oid) end |