Sha256: 5ee89d898d9c7b1f1435afbcd9e1a5bb1327e078dfd8258577ce68c52e2ab1b3

Contents?: true

Size: 798 Bytes

Versions: 5

Compression:

Stored size: 798 Bytes

Contents

# encoding: utf-8

module Flak

  # Module that contains flak error functions
  module Errors



    # Assert that a variable exists and has the correct type.
    # Prints a bright red informative message if not.
    # @param var [String] the variable's name
    # @param type [String] the variable's type
    # @param bind [Binding] the binding for the calling object so that the variable can be evaluated.
    # @param file [String] the filename where the call for this assertion came from.
    # @return [String] formatted error message.
    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





  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
flak-0.0.9 lib/flak/rake/errors.rb
flak-0.0.8 lib/flak/rake/errors.rb
flak-0.0.7 lib/flak/rake/errors.rb
flak-0.0.6 lib/flak/rake/errors.rb
flak-0.0.5 lib/flak/rake/errors.rb