Class: Herb::AST::ERBYieldNode

Inherits:
Node
  • Object
show all
Includes:
Colors
Defined in:
lib/herb/ast/nodes.rb,
sig/herb/ast/nodes.rbs,
ext/herb/nodes.c

Overview

: type serialized_erb_yield_node = { | tag_opening: Herb::Token?, | content: Herb::Token?, | tag_closing: Herb::Token?, | }

Constant Summary

Constants included from Colors

Colors::CLEAR_SCREEN, Colors::HIDE_CURSOR, Colors::SHOW_CURSOR

Instance Attribute Summary collapse

Attributes inherited from Node

#errors, #location, #source, #type

Instance Method Summary collapse

Methods included from Colors

bold, bright_magenta, cyan, dimmed, enabled?, fg, fg_bg, green, magenta, red, #self?.bold, #self?.bright_magenta, #self?.cyan, #self?.dimmed, #self?.enabled?, #self?.fg, #self?.fg_bg, #self?.green, #self?.magenta, #self?.red, #self?.white, #self?.yellow, 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) ⇒ ERBYieldNode

: (String, Location, Array, Herb::Token, Herb::Token, Herb::Token) -> void

Parameters:



4164
4165
4166
4167
4168
4169
# File 'lib/herb/ast/nodes.rb', line 4164

def initialize(type, location, errors, tag_opening, content, tag_closing)
  super(type, location, errors)
  @tag_opening = tag_opening
  @content = content
  @tag_closing = tag_closing
end

Instance Attribute Details

#contentHerb::Token? (readonly)

: Herb::Token?

Returns:



4160
4161
4162
# File 'lib/herb/ast/nodes.rb', line 4160

def content
  @content
end

#tag_closingHerb::Token? (readonly)

: Herb::Token?

Returns:



4161
4162
4163
# File 'lib/herb/ast/nodes.rb', line 4161

def tag_closing
  @tag_closing
end

#tag_openingHerb::Token? (readonly)

: Herb::Token?

Returns:



4159
4160
4161
# File 'lib/herb/ast/nodes.rb', line 4159

def tag_opening
  @tag_opening
end

Instance Method Details

#accept(visitor) ⇒ void

This method returns an undefined value.

: (Visitor) -> void

Parameters:



4181
4182
4183
# File 'lib/herb/ast/nodes.rb', line 4181

def accept(visitor)
  visitor.visit_erb_yield_node(self)
end

#child_nodesArray[Herb::AST::Node?]

: () -> Array

Returns:



4186
4187
4188
# File 'lib/herb/ast/nodes.rb', line 4186

def child_nodes
  []
end

#compact_child_nodesArray[Herb::AST::Node]

: () -> Array

Returns:



4191
4192
4193
# File 'lib/herb/ast/nodes.rb', line 4191

def compact_child_nodes
  child_nodes.compact
end

#inspectString

: () -> String

Returns:

  • (String)


4196
4197
4198
# File 'lib/herb/ast/nodes.rb', line 4196

def inspect
  tree_inspect.rstrip.gsub(/\s+$/, "")
end

#to_hashserialized_erb_yield_node

: () -> serialized_erb_yield_node

Returns:

  • (serialized_erb_yield_node)


4172
4173
4174
4175
4176
4177
4178
# File 'lib/herb/ast/nodes.rb', line 4172

def to_hash
  super.merge({
    tag_opening: tag_opening,
    content: content,
    tag_closing: tag_closing,
  }) #: Herb::serialized_erb_yield_node
end

#tree_inspect(indent: 0, depth: 0, depth_limit: 10) ⇒ String

: (?indent: Integer, ?depth: Integer, ?depth_limit: Integer) -> String

Parameters:

  • indent: (Integer) (defaults to: 0)
  • depth: (Integer) (defaults to: 0)
  • depth_limit: (Integer) (defaults to: 10)

Returns:

  • (String)


4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
# File 'lib/herb/ast/nodes.rb', line 4201

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 += "\n"

  output.gsub(/^/, "    " * indent)
end