Module: Kernel

Defined in:
lib/pretty_debug.rb,
lib/pretty_debug.rb,
lib/pretty_debug.rb

Instance Method Summary collapse

Instance Method Details

#caller_location(i = 1) ⇒ Object



16
# File 'lib/pretty_debug.rb', line 16

def caller_location i = 1; caller_locations(i + 1, 1).first end

#class_check(v, klass, &pr) ⇒ Object



42
43
44
45
46
47
# File 'lib/pretty_debug.rb', line 42

def class_check v, klass, &pr
	unless v.kind_of?(klass)
		ArgumentError.raise(
			"#{pr.call + " " if pr}should be #{klass.expand} instance but is #{v.expand}")
	end
end

#load_relative(f, *rest) ⇒ Object



17
# File 'lib/pretty_debug.rb', line 17

def load_relative f, *rest; load(File.expand_path(f, caller_location.dirname), *rest) end

#old_raiseObject



83
# File 'lib/pretty_debug.rb', line 83

alias old_raise :raise

#raise(*args) ⇒ Object



84
85
86
87
88
89
# File 'lib/pretty_debug.rb', line 84

def raise *args
	old_raise *args
rescue => e
	e.backtrace_locations = caller_locations
	old_raise(e)
end

#suppress_warningObject

Suppress warning message (“already initialized constants”, etc.).



78
79
80
81
82
# File 'lib/pretty_debug.rb', line 78

def suppress_warning
	original_verbose, $VERBOSE = $VERBOSE, nil
	yield
	$VERBOSE =  original_verbose
end