Class HTree::Elem
In: htree/modules.rb
htree/elem.rb
Parent: Object

Methods

Included Modules

Container Trav

Classes and Modules

Module HTree::Elem::Trav
Class HTree::Elem::Loc

Public Class methods

The first argument name should be an instance of String or HTree::Name.

The rest of arguments should be a sequence of follows.

Hash object
used as attributes.
String object
specified string is converted to HTree::Text.
HTree::Node object
used as a child.
HTree::Doc object
used as children. It is expanded except HTree::XMLDecl and HTree::DocType objects.
Array of String, HTree::Node, HTree::Doc
used as children.
HTree::Context object
used as as context which represents XML namespaces. This should apper once at most.

HTree::Location object is accepted just as HTree::Node.

If the rest arguments consists only Hash and HTree::Context, empty element is created.

  p HTree::Elem.new("e").empty_element?     # => true
  p HTree::Elem.new("e", []).empty_element? # => false

Public Instance methods

element_name returns the name of the element name as a Name object.

The argument pairs should be a hash or an assocs.

The key of pairs should be one of following.

HTree::Name or String object
attribute name.
Integer object
child index.

The value of pairs should be one of follows.

HTree::Node object
specified object is used as is.
String object
specified string is converted to HTree::Text
Array of above
specified HTree::Node and String is used in that order.
nil
delete corresponding node.
  e = HTree('<r><a/><b/><c/></r>').root
  p e.subst_subnode({0=>HTree('<x/>'), 2=>HTree('<z/>')})
  p e.subst_subnode([[0, HTree('<x/>')], [2,HTree('<z/>')]])
  # =>
  {elem <r> {emptyelem <x>} {emptyelem <b>} {emptyelem <z>}}
  {elem <r> {emptyelem <x>} {emptyelem <b>} {emptyelem <z>}}

Protected Instance methods

[Validate]