Class: Cybertrain::Test::HtmlNode
- Inherits:
-
Object
- Object
- Cybertrain::Test::HtmlNode
- Defined in:
- cybertrain/test/html_reader.rb
Overview
One element of a document HtmlReader.parse read.
Instance Attribute Summary collapse
-
#node_children ⇒ Array<HtmlNode>
readonly
The child elements, in document order (text is not a node).
-
#node_index ⇒ Integer
readonly
The position of this element in the document order Array HtmlReader.parse answers.
-
#node_parent_index ⇒ Integer
readonly
The position of the parent element in that Array; -1 for an element at the top of the document.
-
#node_tag ⇒ String
readonly
The lower-cased tag name (
"div").
Instance Method Summary collapse
-
#node_attr(name) ⇒ String
The attribute’s value, references decoded; “” when the element has no such attribute (see #node_attr?).
-
#node_attr?(name) ⇒ Boolean
Whether the element has the attribute (a boolean one included).
-
#node_attr_names ⇒ Array<String>
The attribute names, lower-cased, in source order.
-
#node_html ⇒ String
The element’s source, from its
<to the end of its end tag. -
#node_text ⇒ String
The text of every descendant, references decoded, as written (
script/stylecontent included, raw);assert_select’stext:compares it after collapsing whitespace.
Instance Attribute Details
#node_children ⇒ Array<HtmlNode> (readonly)
The child elements, in document order (text is not a node).
71 72 73 |
# File 'cybertrain/test/html_reader.rb', line 71 def node_children @node_children end |
#node_index ⇒ Integer (readonly)
The position of this element in the document order Array HtmlReader.parse answers.
60 61 62 |
# File 'cybertrain/test/html_reader.rb', line 60 def node_index @node_index end |
#node_parent_index ⇒ Integer (readonly)
The position of the parent element in that Array; -1 for an element at the top of the document.
66 67 68 |
# File 'cybertrain/test/html_reader.rb', line 66 def node_parent_index @node_parent_index end |
#node_tag ⇒ String (readonly)
The lower-cased tag name ("div").
54 55 56 |
# File 'cybertrain/test/html_reader.rb', line 54 def node_tag @node_tag end |
Instance Method Details
#node_attr(name) ⇒ String
The attribute’s value, references decoded; “” when the element has no such attribute (see #node_attr?). The name is lower-cased.
92 93 94 95 96 97 |
# File 'cybertrain/test/html_reader.rb', line 92 def node_attr(name) k = attr_position(name) return "" if k < 0 @attr_values[k] end |
#node_attr?(name) ⇒ Boolean
Whether the element has the attribute (a boolean one included).
103 104 105 |
# File 'cybertrain/test/html_reader.rb', line 103 def node_attr?(name) attr_position(name) >= 0 end |
#node_attr_names ⇒ Array<String>
The attribute names, lower-cased, in source order.
110 111 112 |
# File 'cybertrain/test/html_reader.rb', line 110 def node_attr_names @attr_names end |
#node_html ⇒ String
The element’s source, from its < to the end of its end tag.
126 127 128 |
# File 'cybertrain/test/html_reader.rb', line 126 def node_html @node_html end |
#node_text ⇒ String
The text of every descendant, references decoded, as written
(script / style content included, raw); assert_select’s
text: compares it after collapsing whitespace.
119 120 121 |
# File 'cybertrain/test/html_reader.rb', line 119 def node_text @node_text end |