Class: Herb::AST::RubyHTMLAttributesSplatNode

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_ruby_html_attributes_splat_node = { | content: String?, | prefix: String?, | }

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, content, prefix) ⇒ RubyHTMLAttributesSplatNode

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

Parameters:



1108
1109
1110
1111
1112
# File 'lib/herb/ast/nodes.rb', line 1108

def initialize(type, location, errors, content, prefix)
  super(type, location, errors)
  @content = content&.force_encoding("utf-8")
  @prefix = prefix&.force_encoding("utf-8")
end

Instance Attribute Details

#contentString? (readonly)

: String?

Returns:

  • (String, nil)


1104
1105
1106
# File 'lib/herb/ast/nodes.rb', line 1104

def content
  @content
end

#prefixString? (readonly)

: String?

Returns:

  • (String, nil)


1105
1106
1107
# File 'lib/herb/ast/nodes.rb', line 1105

def prefix
  @prefix
end

Instance Method Details

#accept(visitor) ⇒ void

This method returns an undefined value.

: (Visitor) -> void

Parameters:



1123
1124
1125
# File 'lib/herb/ast/nodes.rb', line 1123

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

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

: () -> Array

Returns:



1128
1129
1130
# File 'lib/herb/ast/nodes.rb', line 1128

def child_nodes
  []
end

#compact_child_nodesArray[Herb::AST::Node]

: () -> Array

Returns:



1133
1134
1135
# File 'lib/herb/ast/nodes.rb', line 1133

def compact_child_nodes
  child_nodes.compact
end

#inspectString

: () -> String

Returns:

  • (String)


1138
1139
1140
# File 'lib/herb/ast/nodes.rb', line 1138

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

#to_hashserialized_ruby_html_attributes_splat_node

: () -> serialized_ruby_html_attributes_splat_node

Returns:

  • (serialized_ruby_html_attributes_splat_node)


1115
1116
1117
1118
1119
1120
# File 'lib/herb/ast/nodes.rb', line 1115

def to_hash
  super.merge({
    content: content,
    prefix: prefix,
  }) #: Herb::serialized_ruby_html_attributes_splat_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)


1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
# File 'lib/herb/ast/nodes.rb', line 1143

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("├── content: ") + green("#{content.inspect}\n")
  output += white("└── prefix: ") + green("#{prefix.inspect}\n")
  output += "\n"

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