Class: Herb::Errors::MissingClosingTagError

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, opening_tag) ⇒ MissingClosingTagError

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



201
202
203
204
# File 'lib/herb/errors.rb', line 201

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

Instance Attribute Details

#opening_tagObject (readonly)

| opening_tag: Herb::Token?, | }



198
199
200
# File 'lib/herb/errors.rb', line 198

def opening_tag
  @opening_tag
end

Instance Method Details

#inspectObject

: () -> String



207
208
209
# File 'lib/herb/errors.rb', line 207

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

#to_hashObject

: () -> serialized_missing_closing_tag_error



212
213
214
215
216
# File 'lib/herb/errors.rb', line 212

def to_hash
  super.merge(
    opening_tag: opening_tag
  ) #: Herb::serialized_missing_closing_tag_error
end

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

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



219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/herb/errors.rb', line 219

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("└── opening_tag: ")
  output += opening_tag ? opening_tag.tree_inspect : magenta("")
  output += "\n"
  output += %(\n)

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