Class: Herb::AST::HTMLOmittedCloseTagNode
- Includes:
- Colors
- Defined in:
- lib/herb/ast/nodes.rb,
ext/herb/nodes.c
Overview
: type serialized_html_omitted_close_tag_node = { | tag_name: Herb::Token?, | }
Constant Summary
Constants included from Colors
Colors::CLEAR_SCREEN, Colors::HIDE_CURSOR, Colors::SHOW_CURSOR
Instance Attribute Summary collapse
-
#tag_name ⇒ Object
readonly
: Herb::Token?.
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, tag_name) ⇒ HTMLOmittedCloseTagNode
constructor
: (String, Location, Array, Herb::Token) -> void.
-
#inspect ⇒ Object
: () -> String.
-
#to_hash ⇒ Object
: () -> serialized_html_omitted_close_tag_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, tag_name) ⇒ HTMLOmittedCloseTagNode
: (String, Location, Array, Herb::Token) -> void
439 440 441 442 |
# File 'lib/herb/ast/nodes.rb', line 439 def initialize(type, location, errors, tag_name) super(type, location, errors) @tag_name = tag_name end |
Instance Attribute Details
#tag_name ⇒ Object (readonly)
: Herb::Token?
436 437 438 |
# File 'lib/herb/ast/nodes.rb', line 436 def tag_name @tag_name end |
Instance Method Details
#accept(visitor) ⇒ Object
: (Visitor) -> void
452 453 454 |
# File 'lib/herb/ast/nodes.rb', line 452 def accept(visitor) visitor.visit_html_omitted_close_tag_node(self) end |
#child_nodes ⇒ Object
: () -> Array
457 458 459 |
# File 'lib/herb/ast/nodes.rb', line 457 def child_nodes [] end |
#compact_child_nodes ⇒ Object
: () -> Array
462 463 464 |
# File 'lib/herb/ast/nodes.rb', line 462 def compact_child_nodes child_nodes.compact end |
#inspect ⇒ Object
: () -> String
467 468 469 |
# File 'lib/herb/ast/nodes.rb', line 467 def inspect tree_inspect.rstrip.gsub(/\s+$/, "") end |
#to_hash ⇒ Object
: () -> serialized_html_omitted_close_tag_node
445 446 447 448 449 |
# File 'lib/herb/ast/nodes.rb', line 445 def to_hash super.merge({ tag_name: tag_name, }) #: Herb::serialized_html_omitted_close_tag_node end |
#tree_inspect(indent: 0, depth: 0, depth_limit: 10) ⇒ Object
: (?indent: Integer, ?depth: Integer, ?depth_limit: Integer) -> String
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 |
# File 'lib/herb/ast/nodes.rb', line 472 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("└── tag_name: ") output += tag_name ? tag_name.tree_inspect : magenta("∅") output += "\n" output += "\n" output.gsub(/^/, " " * indent) end |