Method: PlainText::Util.raise_typeerror

Defined in:
lib/plain_text/util.rb

.raise_typeerror(var, to_class, verbose: $DEBUG) ⇒ Object

Raise TypeError

Call as raise_typeerror(var_name) from instance methods, providing this Module is included in the Class/Module.

Parameters:

  • var (Object)
  • to_class (String, Class)

    class name converted into.

  • verbose: (Hash) (defaults to: $DEBUG)

    a customizable set of options

Raises:

  • (TypeError)


94
95
96
97
98
# File 'lib/plain_text/util.rb', line 94

def raise_typeerror(var, to_class, verbose: $DEBUG)
  msg1 = (verbose ? sprintf("(<= %s)", var.inspect) : "")
  to_class_str = (to_class.name rescue to_class.to_str)
  raise TypeError, sprintf("no implicit conversion of %s%s into %s", var.class, msg1, to_class_str)
end