Class: A11y::Lint::PhlexNode
- Inherits:
-
Object
- Object
- A11y::Lint::PhlexNode
- Extended by:
- PhlexTags
- Includes:
- BlockInspection
- Defined in:
- lib/a11y/lint/phlex_node.rb
Overview
Wraps a Phlex HTML tag call or helper method call as a queryable node for lint rules.
Constant Summary
Constants included from PhlexTags
A11y::Lint::PhlexTags::HTML_TAGS, A11y::Lint::PhlexTags::TAG_ALIASES
Constants included from BlockInspection
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#block_body_codes ⇒ Object
readonly
Returns the value of attribute block_body_codes.
-
#call_node ⇒ Object
readonly
Returns the value of attribute call_node.
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#tag_name ⇒ Object
readonly
Returns the value of attribute tag_name.
Class Method Summary collapse
- .build_helper(call_node, block_body_codes: nil, block_has_text_children: false) ⇒ Object
- .build_tag(call_node, children: []) ⇒ Object
Instance Method Summary collapse
- #attribute?(name) ⇒ Boolean
- #block_has_text_children? ⇒ Boolean
-
#initialize(line:, tag_name: nil, attributes: {}, call_node: nil, children: [], block_body_codes: nil, block_has_text_children: false) ⇒ PhlexNode
constructor
rubocop:disable Metrics/ParameterLists.
-
#ruby_code ⇒ Object
rubocop:enable Metrics/ParameterLists.
Methods included from PhlexTags
Methods included from BlockInspection
Constructor Details
#initialize(line:, tag_name: nil, attributes: {}, call_node: nil, children: [], block_body_codes: nil, block_has_text_children: false) ⇒ PhlexNode
rubocop:disable Metrics/ParameterLists
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/a11y/lint/phlex_node.rb', line 21 def initialize( line:, tag_name: nil, attributes: {}, call_node: nil, children: [], block_body_codes: nil, block_has_text_children: false ) @tag_name = tag_name @attributes = attributes @call_node = call_node @line = line @children = children @block_body_codes = block_body_codes @block_has_text_children = block_has_text_children end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
11 12 13 |
# File 'lib/a11y/lint/phlex_node.rb', line 11 def attributes @attributes end |
#block_body_codes ⇒ Object (readonly)
Returns the value of attribute block_body_codes.
11 12 13 |
# File 'lib/a11y/lint/phlex_node.rb', line 11 def block_body_codes @block_body_codes end |
#call_node ⇒ Object (readonly)
Returns the value of attribute call_node.
11 12 13 |
# File 'lib/a11y/lint/phlex_node.rb', line 11 def call_node @call_node end |
#children ⇒ Object (readonly)
Returns the value of attribute children.
11 12 13 |
# File 'lib/a11y/lint/phlex_node.rb', line 11 def children @children end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
11 12 13 |
# File 'lib/a11y/lint/phlex_node.rb', line 11 def line @line end |
#tag_name ⇒ Object (readonly)
Returns the value of attribute tag_name.
11 12 13 |
# File 'lib/a11y/lint/phlex_node.rb', line 11 def tag_name @tag_name end |
Class Method Details
.build_helper(call_node, block_body_codes: nil, block_has_text_children: false) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/a11y/lint/phlex_node.rb', line 59 def self.build_helper( call_node, block_body_codes: nil, block_has_text_children: false ) new( call_node: CallNode.new(call_node), line: call_node.location.start_line, block_body_codes: block_body_codes, block_has_text_children: block_has_text_children ) end |
.build_tag(call_node, children: []) ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/a11y/lint/phlex_node.rb', line 49 def self.build_tag(call_node, children: []) name = call_node.name.to_s new( tag_name: html_tag_name(name), attributes: extract_attributes(call_node), line: call_node.location.start_line, children: children ) end |
Instance Method Details
#attribute?(name) ⇒ Boolean
41 42 43 |
# File 'lib/a11y/lint/phlex_node.rb', line 41 def attribute?(name) attributes.key?(name) end |
#block_has_text_children? ⇒ Boolean
45 46 47 |
# File 'lib/a11y/lint/phlex_node.rb', line 45 def block_has_text_children? @block_has_text_children end |
#ruby_code ⇒ Object
rubocop:enable Metrics/ParameterLists
37 38 39 |
# File 'lib/a11y/lint/phlex_node.rb', line 37 def ruby_code nil end |