Class: Smi::Node

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/smi/node.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ptr) ⇒ Node

Returns a new instance of Node.



6
7
8
# File 'lib/smi/node.rb', line 6

def initialize(ptr)
  @struct = ptr
end

Instance Attribute Details

#indexObject

Returns the value of attribute index.



4
5
6
# File 'lib/smi/node.rb', line 4

def index
  @index
end

#structObject

Returns the value of attribute struct.



4
5
6
# File 'lib/smi/node.rb', line 4

def struct
  @struct
end

Class Method Details

.get_node(oid) ⇒ Object



14
15
16
17
18
19
# File 'lib/smi/node.rb', line 14

def self.get_node(oid)
  struct = Wrapper::smiGetNode(nil, oid)
  n = new(struct)
  n.index = oid.split("#{n.oid}.").last
  n
end

Instance Method Details

#childrenObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/smi/node.rb', line 21

def children
  nodes = []
  node = Wrapper::smiGetFirstChildNode(struct.pointer)
  node = self.class.new(node)
  nodes << node
  while !(node = Wrapper::smiGetNextChildNode(node.pointer)).null?
    node = self.class.new(node)
    nodes << node
  end
  nodes
end

#oidObject



10
11
12
# File 'lib/smi/node.rb', line 10

def oid
  @struct.oid.read_array_of_int(@struct.oidlen).join(".")
end