Class: Herb::AST::XMLDeclarationNode
- Includes:
- Colors
- Defined in:
- lib/herb/ast/nodes.rb,
ext/herb/nodes.c
Overview
: type serialized_xml_declaration_node = { | tag_opening: Herb::Token?, | children: Array, | tag_closing: Herb::Token?, | }
Constant Summary
Constants included from Colors
Colors::CLEAR_SCREEN, Colors::HIDE_CURSOR, Colors::SHOW_CURSOR
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
: Array.
-
#tag_closing ⇒ Object
readonly
: Herb::Token?.
-
#tag_opening ⇒ 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_opening, children, tag_closing) ⇒ XMLDeclarationNode constructor
-
#inspect ⇒ Object
: () -> String.
-
#to_hash ⇒ Object
: () -> serialized_xml_declaration_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_opening, children, tag_closing) ⇒ XMLDeclarationNode
1489 1490 1491 1492 1493 1494 |
# File 'lib/herb/ast/nodes.rb', line 1489 def initialize(type, location, errors, tag_opening, children, tag_closing) super(type, location, errors) @tag_opening = tag_opening @children = children @tag_closing = tag_closing end |
Instance Attribute Details
#children ⇒ Object (readonly)
: Array
1485 1486 1487 |
# File 'lib/herb/ast/nodes.rb', line 1485 def children @children end |
#tag_closing ⇒ Object (readonly)
: Herb::Token?
1486 1487 1488 |
# File 'lib/herb/ast/nodes.rb', line 1486 def tag_closing @tag_closing end |
#tag_opening ⇒ Object (readonly)
: Herb::Token?
1484 1485 1486 |
# File 'lib/herb/ast/nodes.rb', line 1484 def tag_opening @tag_opening end |
Instance Method Details
#accept(visitor) ⇒ Object
: (Visitor) -> void
1506 1507 1508 |
# File 'lib/herb/ast/nodes.rb', line 1506 def accept(visitor) visitor.visit_xml_declaration_node(self) end |
#child_nodes ⇒ Object
: () -> Array
1511 1512 1513 |
# File 'lib/herb/ast/nodes.rb', line 1511 def child_nodes [*(children || [])] end |
#compact_child_nodes ⇒ Object
: () -> Array
1516 1517 1518 |
# File 'lib/herb/ast/nodes.rb', line 1516 def compact_child_nodes child_nodes.compact end |
#inspect ⇒ Object
: () -> String
1521 1522 1523 |
# File 'lib/herb/ast/nodes.rb', line 1521 def inspect tree_inspect.rstrip.gsub(/\s+$/, "") end |
#to_hash ⇒ Object
: () -> serialized_xml_declaration_node
1497 1498 1499 1500 1501 1502 1503 |
# File 'lib/herb/ast/nodes.rb', line 1497 def to_hash super.merge({ tag_opening: tag_opening, children: children, tag_closing: tag_closing, }) #: Herb::serialized_xml_declaration_node end |
#tree_inspect(indent: 0, depth: 0, depth_limit: 10) ⇒ Object
: (?indent: Integer, ?depth: Integer, ?depth_limit: Integer) -> String
1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 |
# File 'lib/herb/ast/nodes.rb', line 1526 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_opening: ") output += tag_opening ? tag_opening.tree_inspect : magenta("∅") output += "\n" output += white("├── children: ") output += inspect_array(children, prefix: "│ ", indent: indent, depth: depth + 1, depth_limit: depth_limit) output += white("└── tag_closing: ") output += tag_closing ? tag_closing.tree_inspect : magenta("∅") output += "\n" output += "\n" output.gsub(/^/, " " * indent) end |