Class: Herb::Errors::UnclosedCloseTagError

Inherits:
Error
  • Object
show all
Includes:
Colors
Defined in:
lib/herb/errors.rb,
ext/herb/error_helpers.c

Constant Summary

Constants included from Colors

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

Instance Attribute Summary collapse

Attributes inherited from Error

#location, #message, #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 Error

#class_name, #error_name, #to_json

Constructor Details

#initialize(type, location, message, tag_name) ⇒ UnclosedCloseTagError

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



792
793
794
795
# File 'lib/herb/errors.rb', line 792

def initialize(type, location, message, tag_name)
  super(type, location, message)
  @tag_name = tag_name
end

Instance Attribute Details

#tag_nameObject (readonly)

| tag_name: Herb::Token?, | }



789
790
791
# File 'lib/herb/errors.rb', line 789

def tag_name
  @tag_name
end

Instance Method Details

#inspectObject

: () -> String



798
799
800
# File 'lib/herb/errors.rb', line 798

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

#to_hashObject

: () -> serialized_unclosed_close_tag_error



803
804
805
806
807
# File 'lib/herb/errors.rb', line 803

def to_hash
  super.merge(
    tag_name: tag_name
  ) #: Herb::serialized_unclosed_close_tag_error
end

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

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



810
811
812
813
814
815
816
817
818
819
820
821
# File 'lib/herb/errors.rb', line 810

def tree_inspect(indent: 0, depth: 0, depth_limit: 25)
  output = +""

  output += white("@ #{bold(red(error_name))} #{dimmed("(location: #{location&.tree_inspect})\n")}")
  output += white("├── message: #{green(message.inspect)}\n")
  output += white("└── tag_name: ")
  output += tag_name ? tag_name.tree_inspect : magenta("")
  output += "\n"
  output += %(\n)

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