Module: Flak::Errors

Defined in:
lib/flak/rake/errors.rb

Overview

Module that contains flak error functions

Class Method Summary collapse

Class Method Details

.assert(var, type, bind, file) ⇒ String

Assert that a variable exists and has the correct type. Prints a bright red informative message if not.

Parameters:

  • var (String)

    the variable’s name

  • type (String)

    the variable’s type

  • bind (Binding)

    the binding for the calling object so that the variable can be evaluated.

  • file (String)

    the filename where the call for this assertion came from.

Returns:

  • (String)

    formatted error message.



17
18
19
20
# File 'lib/flak/rake/errors.rb', line 17

def self.assert(var, type, bind, file)
  param = eval(var,bind)
  ap "#{var} is not a #{type}. It is a #{param.class}. (#{File.basename(file)})" , :color => {:string => :red}  unless param.class == Kernel.const_get(type)
end