class Snmp2mkr::Oid
Attributes
name[R]
Public Class Methods
new(obj, mib: nil, name: nil)
click to toggle source
# File lib/snmp2mkr/oid.rb, line 11 def initialize(obj, mib: nil, name: nil) case obj when Array @ary = obj.map(&:to_i) when String if obj.include?('::') @name = obj @ary = mib.name_to_oid(obj) else @ary = obj.split('.').map(&:to_i) end end @str = @ary.map(&:to_s).join('.') case when name @name = name when mib @name ||= mib.oid_to_name(self) end end
Public Instance Methods
==(o)
click to toggle source
# File lib/snmp2mkr/oid.rb, line 43 def ==(o) self.class == o.class && self.to_s == o.to_s end
index_of(o)
click to toggle source
# File lib/snmp2mkr/oid.rb, line 58 def index_of(o) other = Snmp2mkr::Oid(o) raise ArgumntError, "#{o.inspect} is not subtree of #{self.inspect} " unless other.subtree?(self) self.to_a[other.to_a.size..-1].map(&:to_s).join('.') end
inspect()
click to toggle source
# File lib/snmp2mkr/oid.rb, line 64 def inspect "#<#{self.class}: #{to_s}#{@name && " (#{@name})"}>" end
subtree?(o)
click to toggle source
# File lib/snmp2mkr/oid.rb, line 47 def subtree?(o) other = Snmp2mkr::Oid(o) self.to_a.size < other.to_a.size && other.to_a[0,self.to_a.size] == self.to_a end
subtree_of?(o)
click to toggle source
# File lib/snmp2mkr/oid.rb, line 53 def subtree_of?(o) other = Snmp2mkr::Oid(o) other.subtree?(self) end
to_a()
click to toggle source
# File lib/snmp2mkr/oid.rb, line 35 def to_a @ary end
to_s()
click to toggle source
# File lib/snmp2mkr/oid.rb, line 39 def to_s @str end