Class: Herb::Errors::RenderInvalidAsOptionError

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, as_value) ⇒ RenderInvalidAsOptionError

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



1172
1173
1174
1175
# File 'lib/herb/errors.rb', line 1172

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

Instance Attribute Details

#as_valueObject (readonly)

| as_value: String?, | }



1169
1170
1171
# File 'lib/herb/errors.rb', line 1169

def as_value
  @as_value
end

Instance Method Details

#inspectObject

: () -> String



1178
1179
1180
# File 'lib/herb/errors.rb', line 1178

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

#to_hashObject

: () -> serialized_render_invalid_as_option_error



1183
1184
1185
1186
1187
# File 'lib/herb/errors.rb', line 1183

def to_hash
  super.merge(
    as_value: as_value
  ) #: Herb::serialized_render_invalid_as_option_error
end

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

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



1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
# File 'lib/herb/errors.rb', line 1190

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

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