Method: VCDOM::Element#append_child

Defined in:
lib/vcdom/element.rb

#append_child(new_child) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/vcdom/element.rb', line 36

def append_child( new_child )
  # ノードのタイプチェックなど
  if not new_child.is_a? Node then
    raise ArgumentError.new( "the argument [#{new_child.inspect}] is not an object of the expected class." )
  end
  # Element, Text, Comment, ProcessingInstruction, CDATASection, EntityReference
  case new_child.node_type
    when ELEMENT_NODE, TEXT_NODE, CDATA_SECTION_NODE, ENTITY_REFERENCE_NODE, PROCESSING_INSTRUCTION_NODE, COMMENT_NODE then
      # OK
    else
      # ERROR
      raise "ERROR"
  end
  _append_child( new_child )
end