Class: Herb::Errors::MissingOpeningTagError

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, closing_tag) ⇒ MissingOpeningTagError

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



160
161
162
163
# File 'lib/herb/errors.rb', line 160

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

Instance Attribute Details

#closing_tagObject (readonly)

| closing_tag: Herb::Token?, | }



157
158
159
# File 'lib/herb/errors.rb', line 157

def closing_tag
  @closing_tag
end

Instance Method Details

#inspectObject

: () -> String



166
167
168
# File 'lib/herb/errors.rb', line 166

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

#to_hashObject

: () -> serialized_missing_opening_tag_error



171
172
173
174
175
# File 'lib/herb/errors.rb', line 171

def to_hash
  super.merge(
    closing_tag: closing_tag
  ) #: Herb::serialized_missing_opening_tag_error
end

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

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



178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/herb/errors.rb', line 178

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

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