Class: Array

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

Instance Method Summary collapse

Instance Method Details

#===(other) ⇒ Object



232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/wood/node.rb', line 232

def === other
  case other
  when Array
    self.each_with_index do |x, i|
      return false unless x === other[i]
    end
  else
    return false
  end

  return true
end

#child_nodesObject



245
246
247
# File 'lib/wood/node.rb', line 245

def child_nodes
  self
end

#node_nameObject



222
223
224
# File 'lib/wood/node.rb', line 222

def node_name
  :array
end

#parent_node=(parent_node) ⇒ Object



226
227
228
229
230
# File 'lib/wood/node.rb', line 226

def parent_node=(parent_node)
  each do |node|
    node.parent_node = parent_node if node.respond_to?(:parent_node=)
  end
end

#set_child(child_name, node_val) ⇒ Object



251
252
253
254
255
256
257
258
# File 'lib/wood/node.rb', line 251

def set_child(child_name, node_val)
  case node_val
  when nil
    self.delete_at(child_name)
  else
    self[child_name] = node_val
  end
end

#sexpObject



218
219
220
# File 'lib/wood/node.rb', line 218

def sexp
  map(&:sexp)
end