Class: Smi::Node
Instance Attribute Summary collapse
-
#index ⇒ Object
Returns the value of attribute index.
-
#struct ⇒ Object
Returns the value of attribute struct.
Class Method Summary collapse
Instance Method Summary collapse
- #children ⇒ Object
-
#initialize(ptr) ⇒ Node
constructor
A new instance of Node.
- #oid ⇒ Object
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
#index ⇒ Object
Returns the value of attribute index.
4 5 6 |
# File 'lib/smi/node.rb', line 4 def index @index end |
#struct ⇒ Object
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
#children ⇒ Object
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 |
#oid ⇒ Object
10 11 12 |
# File 'lib/smi/node.rb', line 10 def oid @struct.oid.read_array_of_int(@struct.oidlen).join(".") end |