Class: Herb::Errors::VoidElementContentError

Inherits:
Error
  • Object
show all
Includes:
Colors
Defined in:
lib/herb/errors.rb,
sig/herb/errors.rbs,
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, #self?.bold, #self?.bright_magenta, #self?.cyan, #self?.dimmed, #self?.enabled?, #self?.fg, #self?.fg_bg, #self?.green, #self?.magenta, #self?.red, #self?.white, #self?.yellow, 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

Parameters:



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_typeString? (readonly)

: String?

Returns:

  • (String, nil)


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

def content_type
  @content_type
end

#helper_nameString? (readonly)

: String?

Returns:

  • (String, nil)


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

def helper_name
  @helper_name
end

#tag_nameHerb::Token? (readonly)

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

Returns:



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

def tag_name
  @tag_name
end

Instance Method Details

#inspectString

: () -> String

Returns:

  • (String)


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

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

#to_hashserialized_void_element_content_error

: () -> serialized_void_element_content_error

Returns:

  • (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) ⇒ String

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

Parameters:

  • indent: (Integer) (defaults to: 0)
  • depth: (Integer) (defaults to: 0)
  • depth_limit: (Integer) (defaults to: 25)

Returns:

  • (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