Class: Herb::AST::HTMLAttributeValueNode
- Includes:
- Colors
- Defined in:
- lib/herb/ast/nodes.rb,
ext/herb/nodes.c
Overview
: type serialized_html_attribute_value_node = { | open_quote: Herb::Token?, | children: Array, | close_quote: Herb::Token?, | quoted: bool, | }
Constant Summary
Constants included from Colors
Colors::CLEAR_SCREEN, Colors::HIDE_CURSOR, Colors::SHOW_CURSOR
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
: Array.
-
#close_quote ⇒ Object
readonly
: Herb::Token?.
-
#open_quote ⇒ Object
readonly
: Herb::Token?.
-
#quoted ⇒ Object
readonly
: bool.
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, open_quote, children, close_quote, quoted) ⇒ HTMLAttributeValueNode constructor
-
#inspect ⇒ Object
: () -> String.
-
#to_hash ⇒ Object
: () -> serialized_html_attribute_value_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, open_quote, children, close_quote, quoted) ⇒ HTMLAttributeValueNode
811 812 813 814 815 816 817 |
# File 'lib/herb/ast/nodes.rb', line 811 def initialize(type, location, errors, open_quote, children, close_quote, quoted) super(type, location, errors) @open_quote = open_quote @children = children @close_quote = close_quote @quoted = quoted end |
Instance Attribute Details
#children ⇒ Object (readonly)
: Array
806 807 808 |
# File 'lib/herb/ast/nodes.rb', line 806 def children @children end |
#close_quote ⇒ Object (readonly)
: Herb::Token?
807 808 809 |
# File 'lib/herb/ast/nodes.rb', line 807 def close_quote @close_quote end |
#open_quote ⇒ Object (readonly)
: Herb::Token?
805 806 807 |
# File 'lib/herb/ast/nodes.rb', line 805 def open_quote @open_quote end |
#quoted ⇒ Object (readonly)
: bool
808 809 810 |
# File 'lib/herb/ast/nodes.rb', line 808 def quoted @quoted end |
Instance Method Details
#accept(visitor) ⇒ Object
: (Visitor) -> void
830 831 832 |
# File 'lib/herb/ast/nodes.rb', line 830 def accept(visitor) visitor.visit_html_attribute_value_node(self) end |
#child_nodes ⇒ Object
: () -> Array
835 836 837 |
# File 'lib/herb/ast/nodes.rb', line 835 def child_nodes [*(children || [])] end |
#compact_child_nodes ⇒ Object
: () -> Array
840 841 842 |
# File 'lib/herb/ast/nodes.rb', line 840 def compact_child_nodes child_nodes.compact end |
#inspect ⇒ Object
: () -> String
845 846 847 |
# File 'lib/herb/ast/nodes.rb', line 845 def inspect tree_inspect.rstrip.gsub(/\s+$/, "") end |
#to_hash ⇒ Object
: () -> serialized_html_attribute_value_node
820 821 822 823 824 825 826 827 |
# File 'lib/herb/ast/nodes.rb', line 820 def to_hash super.merge({ open_quote: open_quote, children: children, close_quote: close_quote, quoted: quoted, }) #: Herb::serialized_html_attribute_value_node end |
#tree_inspect(indent: 0, depth: 0, depth_limit: 10) ⇒ Object
: (?indent: Integer, ?depth: Integer, ?depth_limit: Integer) -> String
850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 |
# File 'lib/herb/ast/nodes.rb', line 850 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("├── open_quote: ") output += open_quote ? open_quote.tree_inspect : magenta("∅") output += "\n" output += white("├── children: ") output += inspect_array(children, prefix: "│ ", indent: indent, depth: depth + 1, depth_limit: depth_limit) output += white("├── close_quote: ") output += close_quote ? close_quote.tree_inspect : magenta("∅") output += "\n" output += white("└── quoted: ") output += [true, false].include?(quoted) ? bold(magenta(quoted.to_s)) : magenta("∅") output += "\n" output += "\n" output.gsub(/^/, " " * indent) end |