Class: Herb::AST::ERBRescueNode
- Includes:
- Colors
- Defined in:
- lib/herb/ast/nodes.rb,
ext/herb/nodes.c
Overview
: type serialized_erb_rescue_node = { | tag_opening: Herb::Token?, | content: Herb::Token?, | tag_closing: Herb::Token?, | statements: Array, | subsequent: Herb::AST::ERBRescueNode?, | }
Constant Summary
Constants included from Colors
Colors::CLEAR_SCREEN, Colors::HIDE_CURSOR, Colors::SHOW_CURSOR
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
: Herb::Token?.
-
#statements ⇒ Object
readonly
: Array.
-
#subsequent ⇒ Object
readonly
: Herb::AST::ERBRescueNode?.
-
#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, content, tag_closing, statements, subsequent) ⇒ ERBRescueNode constructor
-
#inspect ⇒ Object
: () -> String.
-
#to_hash ⇒ Object
: () -> serialized_erb_rescue_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, content, tag_closing, statements, subsequent) ⇒ ERBRescueNode
3044 3045 3046 3047 3048 3049 3050 3051 |
# File 'lib/herb/ast/nodes.rb', line 3044 def initialize(type, location, errors, tag_opening, content, tag_closing, statements, subsequent) super(type, location, errors) @tag_opening = tag_opening @content = content @tag_closing = tag_closing @statements = statements @subsequent = subsequent end |
Instance Attribute Details
#content ⇒ Object (readonly)
: Herb::Token?
3038 3039 3040 |
# File 'lib/herb/ast/nodes.rb', line 3038 def content @content end |
#statements ⇒ Object (readonly)
: Array
3040 3041 3042 |
# File 'lib/herb/ast/nodes.rb', line 3040 def statements @statements end |
#subsequent ⇒ Object (readonly)
: Herb::AST::ERBRescueNode?
3041 3042 3043 |
# File 'lib/herb/ast/nodes.rb', line 3041 def subsequent @subsequent end |
#tag_closing ⇒ Object (readonly)
: Herb::Token?
3039 3040 3041 |
# File 'lib/herb/ast/nodes.rb', line 3039 def tag_closing @tag_closing end |
#tag_opening ⇒ Object (readonly)
: Herb::Token?
3037 3038 3039 |
# File 'lib/herb/ast/nodes.rb', line 3037 def tag_opening @tag_opening end |
Instance Method Details
#accept(visitor) ⇒ Object
: (Visitor) -> void
3065 3066 3067 |
# File 'lib/herb/ast/nodes.rb', line 3065 def accept(visitor) visitor.visit_erb_rescue_node(self) end |
#child_nodes ⇒ Object
: () -> Array
3070 3071 3072 |
# File 'lib/herb/ast/nodes.rb', line 3070 def child_nodes [*(statements || []), subsequent] end |
#compact_child_nodes ⇒ Object
: () -> Array
3075 3076 3077 |
# File 'lib/herb/ast/nodes.rb', line 3075 def compact_child_nodes child_nodes.compact end |
#inspect ⇒ Object
: () -> String
3080 3081 3082 |
# File 'lib/herb/ast/nodes.rb', line 3080 def inspect tree_inspect.rstrip.gsub(/\s+$/, "") end |
#to_hash ⇒ Object
: () -> serialized_erb_rescue_node
3054 3055 3056 3057 3058 3059 3060 3061 3062 |
# File 'lib/herb/ast/nodes.rb', line 3054 def to_hash super.merge({ tag_opening: tag_opening, content: content, tag_closing: tag_closing, statements: statements, subsequent: subsequent, }) #: Herb::serialized_erb_rescue_node end |
#tree_inspect(indent: 0, depth: 0, depth_limit: 10) ⇒ Object
: (?indent: Integer, ?depth: Integer, ?depth_limit: Integer) -> String
3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 |
# File 'lib/herb/ast/nodes.rb', line 3085 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("├── content: ") output += content ? content.tree_inspect : magenta("∅") output += "\n" output += white("├── tag_closing: ") output += tag_closing ? tag_closing.tree_inspect : magenta("∅") output += "\n" output += white("├── statements: ") output += inspect_array(statements, prefix: "│ ", indent: indent, depth: depth + 1, depth_limit: depth_limit) output += white("└── subsequent: ") if subsequent output += "\n" output += " └── " output += subsequent.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 |