Class: Herb::Errors::VoidElementClosingTagError
- 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
-
#expected ⇒ Object
readonly
: String?.
-
#found ⇒ Object
readonly
: String?.
-
#tag_name ⇒ Object
readonly
| tag_name: Herb::Token?, | expected: String?, | found: String?, | }.
Attributes inherited from Error
Instance Method Summary collapse
-
#initialize(type, location, message, tag_name, expected, found) ⇒ VoidElementClosingTagError
constructor
: (String, Location?, String, Herb::Token, String, String) -> void.
-
#inspect ⇒ Object
: () -> String.
-
#to_hash ⇒ Object
: () -> serialized_void_element_closing_tag_error.
-
#tree_inspect(indent: 0, depth: 0, depth_limit: 25) ⇒ Object
: (?indent: Integer, ?depth: Integer, ?depth_limit: Integer) -> String.
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, expected, found) ⇒ VoidElementClosingTagError
: (String, Location?, String, Herb::Token, String, String) -> void
294 295 296 297 298 299 |
# File 'lib/herb/errors.rb', line 294 def initialize(type, location, , tag_name, expected, found) super(type, location, ) @tag_name = tag_name @expected = expected @found = found end |
Instance Attribute Details
#expected ⇒ Object (readonly)
: String?
290 291 292 |
# File 'lib/herb/errors.rb', line 290 def expected @expected end |
#found ⇒ Object (readonly)
: String?
291 292 293 |
# File 'lib/herb/errors.rb', line 291 def found @found end |
#tag_name ⇒ Object (readonly)
| tag_name: Herb::Token?, | expected: String?, | found: String?, | }
289 290 291 |
# File 'lib/herb/errors.rb', line 289 def tag_name @tag_name end |
Instance Method Details
#inspect ⇒ Object
: () -> String
302 303 304 |
# File 'lib/herb/errors.rb', line 302 def inspect tree_inspect.rstrip.gsub(/\s+$/, "") end |
#to_hash ⇒ Object
: () -> serialized_void_element_closing_tag_error
307 308 309 310 311 312 313 |
# File 'lib/herb/errors.rb', line 307 def to_hash super.merge( tag_name: tag_name, expected: expected, found: found ) #: Herb::serialized_void_element_closing_tag_error end |
#tree_inspect(indent: 0, depth: 0, depth_limit: 25) ⇒ Object
: (?indent: Integer, ?depth: Integer, ?depth_limit: Integer) -> String
316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
# File 'lib/herb/errors.rb', line 316 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(.inspect)}\n") output += white("├── tag_name: ") output += tag_name ? tag_name.tree_inspect : magenta("∅") output += "\n" output += white("├── expected: #{green(expected.inspect)}\n") output += white("└── found: #{green(found.inspect)}\n") output += %(\n) output.gsub(/^/, " " * indent) end |