Class: Herb::Errors::VoidElementContentError

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, helper_name, content_type) ⇒ VoidElementContentError

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



1450
1451
1452
1453
1454
1455
# File 'lib/herb/errors.rb', line 1450

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

Instance Attribute Details

#content_typeObject (readonly)

: String?



1447
1448
1449
# File 'lib/herb/errors.rb', line 1447

def content_type
  @content_type
end

#helper_nameObject (readonly)

: String?



1446
1447
1448
# File 'lib/herb/errors.rb', line 1446

def helper_name
  @helper_name
end

#tag_nameObject (readonly)

| tag_name: Herb::Token?, | helper_name: String?, | content_type: String?, | }



1445
1446
1447
# File 'lib/herb/errors.rb', line 1445

def tag_name
  @tag_name
end

Instance Method Details

#inspectObject

: () -> String



1458
1459
1460
# File 'lib/herb/errors.rb', line 1458

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

#to_hashObject

: () -> serialized_void_element_content_error



1463
1464
1465
1466
1467
1468
1469
# File 'lib/herb/errors.rb', line 1463

def to_hash
  super.merge(
    tag_name: tag_name,
    helper_name: helper_name,
    content_type: content_type
  ) #: Herb::serialized_void_element_content_error
end

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

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



1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
# File 'lib/herb/errors.rb', line 1472

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 += white("├── helper_name: #{green(helper_name.inspect)}\n")
  output += white("└── content_type: #{green(content_type.inspect)}\n")
  output += %(\n)

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