Class: Cybertrain::Test::HtmlNode

Inherits:
Object
  • Object
show all
Defined in:
cybertrain/test/html_reader.rb

Overview

One element of a document HtmlReader.parse read.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#node_children ⇒ Array<HtmlNode> (readonly)

The child elements, in document order (text is not a node).

Returns:



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.

Returns:



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.

Returns:



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").

Returns:

  • (String)


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.

Parameters:

  • name (String)

Returns:

  • (String)


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).

Parameters:

  • name (String)

Returns:

  • (Boolean)


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.

Returns:

  • (Array<String>)


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.

Returns:

  • (String)


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.

Returns:

  • (String)


119
120
121
# File 'cybertrain/test/html_reader.rb', line 119

def node_text
  @node_text
end