Class: Herb::AST::ERBEndNode

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

Overview

: type serialized_erb_end_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, 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) ⇒ ERBEndNode

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



1833
1834
1835
1836
1837
1838
# File 'lib/herb/ast/nodes.rb', line 1833

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

#contentObject (readonly)

: Herb::Token?



1829
1830
1831
# File 'lib/herb/ast/nodes.rb', line 1829

def content
  @content
end

#tag_closingObject (readonly)

: Herb::Token?



1830
1831
1832
# File 'lib/herb/ast/nodes.rb', line 1830

def tag_closing
  @tag_closing
end

#tag_openingObject (readonly)

: Herb::Token?



1828
1829
1830
# File 'lib/herb/ast/nodes.rb', line 1828

def tag_opening
  @tag_opening
end

Instance Method Details

#accept(visitor) ⇒ Object

: (Visitor) -> void



1850
1851
1852
# File 'lib/herb/ast/nodes.rb', line 1850

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

#child_nodesObject

: () -> Array



1855
1856
1857
# File 'lib/herb/ast/nodes.rb', line 1855

def child_nodes
  []
end

#compact_child_nodesObject

: () -> Array



1860
1861
1862
# File 'lib/herb/ast/nodes.rb', line 1860

def compact_child_nodes
  child_nodes.compact
end

#inspectObject

: () -> String



1865
1866
1867
# File 'lib/herb/ast/nodes.rb', line 1865

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

#to_hashObject

: () -> serialized_erb_end_node



1841
1842
1843
1844
1845
1846
1847
# File 'lib/herb/ast/nodes.rb', line 1841

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

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

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



1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
# File 'lib/herb/ast/nodes.rb', line 1870

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