Class: Herb::AST::HTMLAttributeNameNode
- Includes:
- Colors
- Defined in:
- lib/herb/ast/nodes.rb,
ext/herb/nodes.c
Overview
: type serialized_html_attribute_name_node = { | children: Array[(Herb::AST::LiteralNode | Herb::AST::ERBContentNode)]?, | }
Constant Summary
Constants included from Colors
Colors::CLEAR_SCREEN, Colors::HIDE_CURSOR, Colors::SHOW_CURSOR
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
: Array[(Herb::AST::LiteralNode | Herb::AST::ERBContentNode)]?.
Attributes inherited from Node
#errors, #location, #source, #type
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
: (Visitor) -> void.
-
#child_nodes ⇒ Object
: () -> Array.
-
#compact_child_nodes ⇒ Object
: () -> Array.
-
#initialize(type, location, errors, children) ⇒ HTMLAttributeNameNode
constructor
: (String, Location, Array, Array[(Herb::AST::LiteralNode | Herb::AST::ERBContentNode)]) -> void.
-
#inspect ⇒ Object
: () -> String.
-
#to_hash ⇒ Object
: () -> serialized_html_attribute_name_node.
-
#tree_inspect(indent: 0, depth: 0, depth_limit: 10) ⇒ Object
: (?indent: Integer, ?depth: Integer, ?depth_limit: Integer) -> String.
Methods included from Colors
bold, bright_magenta, cyan, dimmed, enabled?, fg, fg_bg, green, magenta, red, white, yellow
Methods inherited from Node
#class_name, #inspect_array, #inspect_errors, #node_name, #recursive_errors, #to_json
Constructor Details
#initialize(type, location, errors, children) ⇒ HTMLAttributeNameNode
: (String, Location, Array, Array[(Herb::AST::LiteralNode | Herb::AST::ERBContentNode)]) -> void
890 891 892 893 |
# File 'lib/herb/ast/nodes.rb', line 890 def initialize(type, location, errors, children) super(type, location, errors) @children = children end |
Instance Attribute Details
#children ⇒ Object (readonly)
: Array[(Herb::AST::LiteralNode | Herb::AST::ERBContentNode)]?
887 888 889 |
# File 'lib/herb/ast/nodes.rb', line 887 def children @children end |
Instance Method Details
#accept(visitor) ⇒ Object
: (Visitor) -> void
903 904 905 |
# File 'lib/herb/ast/nodes.rb', line 903 def accept(visitor) visitor.visit_html_attribute_name_node(self) end |
#child_nodes ⇒ Object
: () -> Array
908 909 910 |
# File 'lib/herb/ast/nodes.rb', line 908 def child_nodes [*(children || [])] end |
#compact_child_nodes ⇒ Object
: () -> Array
913 914 915 |
# File 'lib/herb/ast/nodes.rb', line 913 def compact_child_nodes child_nodes.compact end |
#inspect ⇒ Object
: () -> String
918 919 920 |
# File 'lib/herb/ast/nodes.rb', line 918 def inspect tree_inspect.rstrip.gsub(/\s+$/, "") end |
#to_hash ⇒ Object
: () -> serialized_html_attribute_name_node
896 897 898 899 900 |
# File 'lib/herb/ast/nodes.rb', line 896 def to_hash super.merge({ children: children, }) #: Herb::serialized_html_attribute_name_node end |
#tree_inspect(indent: 0, depth: 0, depth_limit: 10) ⇒ Object
: (?indent: Integer, ?depth: Integer, ?depth_limit: Integer) -> String
923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 |
# File 'lib/herb/ast/nodes.rb', line 923 def tree_inspect(indent: 0, depth: 0, depth_limit: 10) output = +"" output += white("@ #{bold(yellow(node_name.to_s))} #{dimmed("(location: #{location.tree_inspect})")}") output += "\n" if depth >= depth_limit output += dimmed("└── [depth limit reached ...]\n\n") return output.gsub(/^/, " " * indent) end output += inspect_errors(prefix: "│ ") output += white("└── children: ") output += inspect_array(children, prefix: " ", indent: indent, depth: depth + 1, depth_limit: depth_limit) output += "\n" output.gsub(/^/, " " * indent) end |