Created
July 2, 2015 07:48
-
-
Save 0x0dea/67eba815d4a22c1c225e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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