Class: Herb::AST::HTMLVirtualCloseTagNode
- Includes:
- Colors
- Defined in:
- lib/herb/ast/nodes.rb,
ext/herb/nodes.c
Overview
: type serialized_html_virtual_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) ⇒ HTMLVirtualCloseTagNode
constructor
: (String, Location, Array, Herb::Token) -> void.
-
#inspect ⇒ Object
: () -> String.
-
#to_hash ⇒ Object
: () -> serialized_html_virtual_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) ⇒ HTMLVirtualCloseTagNode
: (String, Location, Array, Herb::Token) -> void
504 505 506 507 |
# File 'lib/herb/ast/nodes.rb', line 504 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?
501 502 503 |
# File 'lib/herb/ast/nodes.rb', line 501 def tag_name @tag_name end |
Instance Method Details
#accept(visitor) ⇒ Object
: (Visitor) -> void
517 518 519 |
# File 'lib/herb/ast/nodes.rb', line 517 def accept(visitor) visitor.visit_html_virtual_close_tag_node(self) end |
#child_nodes ⇒ Object
: () -> Array
522 523 524 |
# File 'lib/herb/ast/nodes.rb', line 522 def child_nodes [] end |
#compact_child_nodes ⇒ Object
: () -> Array
527 528 529 |
# File 'lib/herb/ast/nodes.rb', line 527 def compact_child_nodes child_nodes.compact end |
#inspect ⇒ Object
: () -> String
532 533 534 |
# File 'lib/herb/ast/nodes.rb', line 532 def inspect tree_inspect.rstrip.gsub(/\s+$/, "") end |
#to_hash ⇒ Object
: () -> serialized_html_virtual_close_tag_node
510 511 512 513 514 |
# File 'lib/herb/ast/nodes.rb', line 510 def to_hash super.merge({ tag_name: tag_name, }) #: Herb::serialized_html_virtual_close_tag_node end |
#tree_inspect(indent: 0, depth: 0, depth_limit: 10) ⇒ Object
: (?indent: Integer, ?depth: Integer, ?depth_limit: Integer) -> String
537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 |
# File 'lib/herb/ast/nodes.rb', line 537 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 |