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(*klass, v) ⇒ Object



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

def class_check *klass, v
  case v
  when *klass
  else
    ArgumentError.raise(
      "#{yield + " ".freeze if block_given?}should be #{klass.map(&:expand).join(", ".freeze)} 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.realdirname), *rest) end

#suppress_warningObject

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



101
102
103
104
105
106
# File 'lib/pretty_debug.rb', line 101

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