Class: NicInfo::DataNode

Inherits:
Object
  • Object
show all
Defined in:
lib/nicinfo/data_tree.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, handle = nil, rest_ref = nil, data = nil, data_type = nil) ⇒ DataNode

Returns a new instance of DataNode.



25
26
27
28
29
30
31
32
# File 'lib/nicinfo/data_tree.rb', line 25

def initialize name, handle = nil, rest_ref = nil, data = nil, data_type = nil
  @name = name
  @children = []
  @data = data
  @handle = handle
  @rest_ref = rest_ref
  @data_type = data_type
end

Instance Attribute Details

#alertObject

Returns the value of attribute alert.



23
24
25
# File 'lib/nicinfo/data_tree.rb', line 23

def alert
  @alert
end

#childrenObject

Returns the value of attribute children.



23
24
25
# File 'lib/nicinfo/data_tree.rb', line 23

def children
  @children
end

#dataObject

Returns the value of attribute data.



23
24
25
# File 'lib/nicinfo/data_tree.rb', line 23

def data
  @data
end

#data_typeObject

Returns the value of attribute data_type.



23
24
25
# File 'lib/nicinfo/data_tree.rb', line 23

def data_type
  @data_type
end

#handleObject

Returns the value of attribute handle.



23
24
25
# File 'lib/nicinfo/data_tree.rb', line 23

def handle
  @handle
end

#rest_refObject

Returns the value of attribute rest_ref.



23
24
25
# File 'lib/nicinfo/data_tree.rb', line 23

def rest_ref
  @rest_ref
end

Instance Method Details

#<=>(x) ⇒ Object



46
47
48
# File 'lib/nicinfo/data_tree.rb', line 46

def <=> x
  @name <=> x.to_s
end

#add_child(node) ⇒ Object



34
35
36
# File 'lib/nicinfo/data_tree.rb', line 34

def add_child node
  @children << node if node
end

#empty?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/nicinfo/data_tree.rb', line 42

def empty?
  @children.empty?
end

#has_meta_infoObject



50
51
52
53
54
55
# File 'lib/nicinfo/data_tree.rb', line 50

def has_meta_info
  return true if @handle
  return true if @rest_ref
  return true if @data
  return false
end

#to_sObject



38
39
40
# File 'lib/nicinfo/data_tree.rb', line 38

def to_s
  @name
end