Class: Herb::Errors::ConditionalElementConditionMismatchError

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, open_condition, open_line, open_column, close_condition, close_line, close_column) ⇒ ConditionalElementConditionMismatchError

: (String, Location?, String, String, String, Integer, Integer, String, Integer, Integer) -> void

Parameters:

  • (String)
  • (Location, nil)
  • (String)
  • (String)
  • (String)
  • (Integer)
  • (Integer)
  • (String)
  • (Integer)
  • (Integer)


605
606
607
608
609
610
611
612
613
614
# File 'lib/herb/errors.rb', line 605

def initialize(type, location, message, tag_name, open_condition, open_line, open_column, close_condition, close_line, close_column)
  super(type, location, message)
  @tag_name = tag_name
  @open_condition = open_condition
  @open_line = open_line
  @open_column = open_column
  @close_condition = close_condition
  @close_line = close_line
  @close_column = close_column
end

Instance Attribute Details

#close_columnInteger? (readonly)

: Integer?

Returns:

  • (Integer, nil)


602
603
604
# File 'lib/herb/errors.rb', line 602

def close_column
  @close_column
end

#close_conditionString? (readonly)

: String?

Returns:

  • (String, nil)


600
601
602
# File 'lib/herb/errors.rb', line 600

def close_condition
  @close_condition
end

#close_lineInteger? (readonly)

: Integer?

Returns:

  • (Integer, nil)


601
602
603
# File 'lib/herb/errors.rb', line 601

def close_line
  @close_line
end

#open_columnInteger? (readonly)

: Integer?

Returns:

  • (Integer, nil)


599
600
601
# File 'lib/herb/errors.rb', line 599

def open_column
  @open_column
end

#open_conditionString? (readonly)

: String?

Returns:

  • (String, nil)


597
598
599
# File 'lib/herb/errors.rb', line 597

def open_condition
  @open_condition
end

#open_lineInteger? (readonly)

: Integer?

Returns:

  • (Integer, nil)


598
599
600
# File 'lib/herb/errors.rb', line 598

def open_line
  @open_line
end

#tag_nameString? (readonly)

| tag_name: String?, | open_condition: String?, | open_line: Integer?, | open_column: Integer?, | close_condition: String?, | close_line: Integer?, | close_column: Integer?, | }

Returns:

  • (String, nil)


596
597
598
# File 'lib/herb/errors.rb', line 596

def tag_name
  @tag_name
end

Instance Method Details

#inspectString

: () -> String

Returns:

  • (String)


617
618
619
# File 'lib/herb/errors.rb', line 617

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

#to_hashserialized_conditional_element_condition_mismatch_error

: () -> serialized_conditional_element_condition_mismatch_error

Returns:

  • (serialized_conditional_element_condition_mismatch_error)


622
623
624
625
626
627
628
629
630
631
632
# File 'lib/herb/errors.rb', line 622

def to_hash
  super.merge(
    tag_name: tag_name,
    open_condition: open_condition,
    open_line: open_line,
    open_column: open_column,
    close_condition: close_condition,
    close_line: close_line,
    close_column: close_column
  ) #: Herb::serialized_conditional_element_condition_mismatch_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)


635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
# File 'lib/herb/errors.rb', line 635

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: #{green(tag_name.inspect)}\n")
  output += white("├── open_condition: #{green(open_condition.inspect)}\n")
  output += white("├── open_line: #{green(open_line.inspect)}\n")
  output += white("├── open_column: #{green(open_column.inspect)}\n")
  output += white("├── close_condition: #{green(close_condition.inspect)}\n")
  output += white("├── close_line: #{green(close_line.inspect)}\n")
  output += white("└── close_column: #{green(close_column.inspect)}\n")
  output += %(\n)

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