Class: Dommy::Internal::AccessibilityTree::Node
- Inherits:
-
Object
- Object
- Dommy::Internal::AccessibilityTree::Node
- Defined in:
- lib/dommy/internal/accessibility_tree.rb
Overview
One accessible object. A :text node carries its string in name and
has no children — it is significant text not folded into an ancestor.
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#element ⇒ Object
readonly
Returns the value of attribute element.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
-
#states ⇒ Object
readonly
Returns the value of attribute states.
Instance Method Summary collapse
-
#initialize(role:, name: "", description: "", states: {}, element: nil) ⇒ Node
constructor
A new instance of Node.
-
#level ⇒ Object
The heading level (or any leveled role) lives in
states. - #text? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(role:, name: "", description: "", states: {}, element: nil) ⇒ Node
Returns a new instance of Node.
23 24 25 26 27 28 29 30 |
# File 'lib/dommy/internal/accessibility_tree.rb', line 23 def initialize(role:, name: "", description: "", states: {}, element: nil) @role = role @name = name @description = description @states = states @element = element @children = [] end |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
21 22 23 |
# File 'lib/dommy/internal/accessibility_tree.rb', line 21 def children @children end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
20 21 22 |
# File 'lib/dommy/internal/accessibility_tree.rb', line 20 def description @description end |
#element ⇒ Object (readonly)
Returns the value of attribute element.
20 21 22 |
# File 'lib/dommy/internal/accessibility_tree.rb', line 20 def element @element end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
20 21 22 |
# File 'lib/dommy/internal/accessibility_tree.rb', line 20 def name @name end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
20 21 22 |
# File 'lib/dommy/internal/accessibility_tree.rb', line 20 def role @role end |
#states ⇒ Object (readonly)
Returns the value of attribute states.
20 21 22 |
# File 'lib/dommy/internal/accessibility_tree.rb', line 20 def states @states end |
Instance Method Details
#level ⇒ Object
The heading level (or any leveled role) lives in states.
34 |
# File 'lib/dommy/internal/accessibility_tree.rb', line 34 def level = states[:level] |
#text? ⇒ Boolean
32 33 |
# File 'lib/dommy/internal/accessibility_tree.rb', line 32 def text? = role == :text # The heading level (or any leveled role) lives in `states`. |
#to_h ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/dommy/internal/accessibility_tree.rb', line 36 def to_h hash = {role: role} hash[:name] = name unless name.to_s.empty? hash[:description] = description unless description.to_s.empty? hash[:states] = states unless states.empty? hash[:children] = children.map(&:to_h) unless children.empty? hash end |