Skip to content

Instantly share code, notes, and snippets.

@0x0dea
Created July 2, 2015 07:48
Show Gist options
  • Save 0x0dea/67eba815d4a22c1c225e to your computer and use it in GitHub Desktop.
Save 0x0dea/67eba815d4a22c1c225e to your computer and use it in GitHub Desktop.
require 'stringio'
def find_constant const
return nil unless Object.const_defined? const
value = Object.const_get const
$stderr = StringIO.new
Object.const_set const, nil
$stderr.rewind
ret = $stderr.read.lines.last.split(': ').first
$stderr = STDERR
v, $VERBOSE = $VERBOSE, nil
Object.const_set const, value
$VERBOSE = v
ret
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment