Class: Disp3D::NodeDB

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

Class Method Summary collapse

Class Method Details

.add(node) ⇒ Object



137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/node/node.rb', line 137

def self.add(node)
  Util3D.check_arg_type(Node, node)
  @node_db ||= Hash.new()
  key = node.name
  if(!@node_db.key?(key))
    @node_db[key] = node
  elsif(@node_db[key].kind_of?(Node))
    @node_db[key] = [@node_db[key], node]
  elsif(@node_db[key].kind_of?(Array))
    @node_db[key].push(node)
  else
    raise
  end
end

.delete_by_name(node_name) ⇒ Object



158
159
160
161
# File 'lib/node/node.rb', line 158

def self.delete_by_name(node_name)
  return if @node_db.nil? || node_name.nil?
  @node_db[node_name] = nil
end

.find_by_name(node_name) ⇒ Object



152
153
154
155
156
# File 'lib/node/node.rb', line 152

def self.find_by_name(node_name)
  @node_db ||= Hash.new()
  Util3D.check_arg_type(Symbol, node_name)
  return @node_db[node_name]
end