Class: Herb::Errors::ConditionalElementConditionMismatchError

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

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



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_columnObject (readonly)

: Integer?



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

def close_column
  @close_column
end

#close_conditionObject (readonly)

: String?



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

def close_condition
  @close_condition
end

#close_lineObject (readonly)

: Integer?



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

def close_line
  @close_line
end

#open_columnObject (readonly)

: Integer?



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

def open_column
  @open_column
end

#open_conditionObject (readonly)

: String?



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

def open_condition
  @open_condition
end

#open_lineObject (readonly)

: Integer?



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

def open_line
  @open_line
end

#tag_nameObject (readonly)

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



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

def tag_name
  @tag_name
end

Instance Method Details

#inspectObject

: () -> String



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

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

#to_hashObject

: () -> 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) ⇒ Object

: (?indent: Integer, ?depth: Integer, ?depth_limit: Integer) -> 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