Class: Gammo::Node::Element

Inherits:
Gammo::Node show all
Defined in:
lib/gammo/node.rb

Overview

Represents the element token including start, end and self-closing token.

Constant Summary

Constants inherited from Gammo::Node

Comment, DEFAULT_SCOPE_MARKER, Doctype, Error, ScopeMarker

Instance Attribute Summary

Attributes inherited from Gammo::Node

#attributes, #data, #first_child, #last_child, #namespace, #next_sibling, #parent, #previous_sibling, #tag

Instance Method Summary collapse

Methods inherited from Gammo::Node

#append_child, #children, #document?, #each_descendant, #get_attribute_node, #initialize, #insert_before, #owner_document, #remove_child, #select, #text_content

Constructor Details

This class inherits a constructor from Gammo::Node

Instance Method Details

#inner_textObject

TODO: The current innerText() implementation does not conform to WHATWG spec. html.spec.whatwg.org/multipage/dom.html#the-innertext-idl-attribute



70
71
72
73
74
# File 'lib/gammo/node.rb', line 70

def inner_text
  text = ''
  each_descendant { |node| text << node.data if node.instance_of?(Text) }
  text
end

#to_sObject



76
77
78
79
80
81
# File 'lib/gammo/node.rb', line 76

def to_s
  s = "<#{tag}"
  attrs = attributes_to_string
  s << ' ' unless attrs.empty?
  s << "#{attrs}>"
end