Class: Herb::AST::HTMLAttributeNode
- Includes:
- Colors
- Defined in:
- lib/herb/ast/nodes.rb,
ext/herb/nodes.c
Overview
: type serialized_html_attribute_node = { | name: Herb::AST::HTMLAttributeNameNode?, | equals: Herb::Token?, | value: Herb::AST::HTMLAttributeValueNode?, | }
Constant Summary
Constants included from Colors
Colors::CLEAR_SCREEN, Colors::HIDE_CURSOR, Colors::SHOW_CURSOR
Instance Attribute Summary collapse
-
#equals ⇒ Object
readonly
: Herb::Token?.
-
#name ⇒ Object
readonly
: Herb::AST::HTMLAttributeNameNode?.
-
#value ⇒ Object
readonly
: Herb::AST::HTMLAttributeValueNode?.
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, name, equals, value) ⇒ HTMLAttributeNode
constructor
: (String, Location, Array, Herb::AST::HTMLAttributeNameNode, Herb::Token, Herb::AST::HTMLAttributeValueNode) -> void.
-
#inspect ⇒ Object
: () -> String.
-
#to_hash ⇒ Object
: () -> serialized_html_attribute_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, name, equals, value) ⇒ HTMLAttributeNode
: (String, Location, Array, Herb::AST::HTMLAttributeNameNode, Herb::Token, Herb::AST::HTMLAttributeValueNode) -> void
958 959 960 961 962 963 |
# File 'lib/herb/ast/nodes.rb', line 958 def initialize(type, location, errors, name, equals, value) super(type, location, errors) @name = name @equals = equals @value = value end |
Instance Attribute Details
#equals ⇒ Object (readonly)
: Herb::Token?
954 955 956 |
# File 'lib/herb/ast/nodes.rb', line 954 def equals @equals end |
#name ⇒ Object (readonly)
: Herb::AST::HTMLAttributeNameNode?
953 954 955 |
# File 'lib/herb/ast/nodes.rb', line 953 def name @name end |
#value ⇒ Object (readonly)
: Herb::AST::HTMLAttributeValueNode?
955 956 957 |
# File 'lib/herb/ast/nodes.rb', line 955 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
: (Visitor) -> void
975 976 977 |
# File 'lib/herb/ast/nodes.rb', line 975 def accept(visitor) visitor.visit_html_attribute_node(self) end |
#child_nodes ⇒ Object
: () -> Array
980 981 982 |
# File 'lib/herb/ast/nodes.rb', line 980 def child_nodes [name, value] end |
#compact_child_nodes ⇒ Object
: () -> Array
985 986 987 |
# File 'lib/herb/ast/nodes.rb', line 985 def compact_child_nodes child_nodes.compact end |
#inspect ⇒ Object
: () -> String
990 991 992 |
# File 'lib/herb/ast/nodes.rb', line 990 def inspect tree_inspect.rstrip.gsub(/\s+$/, "") end |
#to_hash ⇒ Object
: () -> serialized_html_attribute_node
966 967 968 969 970 971 972 |
# File 'lib/herb/ast/nodes.rb', line 966 def to_hash super.merge({ name: name, equals: equals, value: value, }) #: Herb::serialized_html_attribute_node end |
#tree_inspect(indent: 0, depth: 0, depth_limit: 10) ⇒ Object
: (?indent: Integer, ?depth: Integer, ?depth_limit: Integer) -> String
995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 |
# File 'lib/herb/ast/nodes.rb', line 995 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("├── name: ") if name output += "\n" output += "│ └── " output += name.tree_inspect(indent: indent, depth: depth + 1, depth_limit: depth_limit).gsub(/^/, " " * (indent + 1)).lstrip.gsub(/^/, "│ ").delete_prefix("│ ") else output += magenta("∅\n") end output += white("├── equals: ") output += equals ? equals.tree_inspect : magenta("∅") output += "\n" output += white("└── value: ") if value output += "\n" output += " └── " output += value.tree_inspect(indent: indent, depth: depth + 1, depth_limit: depth_limit).gsub(/^/, " " * (indent + 1)).lstrip.gsub(/^/, " ").delete_prefix(" ") else output += magenta("∅\n") end output += "\n" output.gsub(/^/, " " * indent) end |