Class: Herb::Errors::OmittedClosingTagError

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

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

Parameters:



705
706
707
708
709
# File 'lib/herb/errors.rb', line 705

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

Instance Attribute Details

#insertion_pointHerb::Position? (readonly)

: Herb::Position?

Returns:



702
703
704
# File 'lib/herb/errors.rb', line 702

def insertion_point
  @insertion_point
end

#opening_tagHerb::Token? (readonly)

| opening_tag: Herb::Token?, | insertion_point: Herb::Position?, | }

Returns:



701
702
703
# File 'lib/herb/errors.rb', line 701

def opening_tag
  @opening_tag
end

Instance Method Details

#inspectString

: () -> String

Returns:

  • (String)


712
713
714
# File 'lib/herb/errors.rb', line 712

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

#to_hashserialized_omitted_closing_tag_error

: () -> serialized_omitted_closing_tag_error

Returns:

  • (serialized_omitted_closing_tag_error)


717
718
719
720
721
722
# File 'lib/herb/errors.rb', line 717

def to_hash
  super.merge(
    opening_tag: opening_tag,
    insertion_point: insertion_point
  ) #: Herb::serialized_omitted_closing_tag_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)


725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
# File 'lib/herb/errors.rb', line 725

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

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