Class: HTMLTree::Document

Inherits:
Object
  • Object
show all
Includes:
TreeElement
Defined in:
lib/html/element.rb,
lib/html/xpath.rb

Overview

This is a Element that represents the whole document (and makes a scope for the DTD declaration)

Instance Method Summary collapse

Methods included from TreeElement

#add_child, #can_have_children?, #children, #content, #dump, #has_children?, #parent, #parent=, #path, #remove_child, #rexml_match, #root

Constructor Details

#initializeDocument

Returns a new instance of Document.



120
121
122
# File 'lib/html/element.rb', line 120

def initialize
  initialize_tree_element(nil, [])
end

Instance Method Details

#as_rexml_document(context = {}) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/html/xpath.rb', line 63

def as_rexml_document(context = {})
  node = REXML::Document.new(nil, context)
  # add DocType
  # add <HTML> node
  html_node.as_rexml_document(node, context)
  node
end

#each(&block) ⇒ Object



128
129
130
# File 'lib/html/element.rb', line 128

def each(&block)
  children.each { |ch| ch.each(&block) }
end

#html_nodeObject

Return my child <html> node, if any.



141
142
143
# File 'lib/html/element.rb', line 141

def html_node
  children.detect { |ea| ea.tag == 'html' }
end

#tagObject



136
137
138
# File 'lib/html/element.rb', line 136

def tag
  ''
end

#to_sObject



124
125
126
# File 'lib/html/element.rb', line 124

def to_s
  ''
end

#write(io) ⇒ Object



132
133
134
# File 'lib/html/element.rb', line 132

def write(io)
  children.each { |t| t.write(io) }
end