Created
June 30, 2019 09:15
-
-
Save ravelll/581d0a8c88f6a68e24d7c3e2513e9693 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
# Classes are from https://docs.ruby-lang.org/ja/2.6.0/library/_builtin.html | |
classes = [ | |
BasicObject, | |
Object, | |
Array, | |
Binding, | |
ConditionVariable, | |
Data, | |
Dir, | |
Encoding, | |
Enumerator, | |
FalseClass, | |
Fiber, | |
Hash, | |
IO, | |
File, | |
MatchData, | |
Method, | |
Module, | |
Class, | |
Mutex, | |
NilClass, | |
Numeric, | |
Bignum, | |
Complex, | |
Fixnum, | |
Float, | |
Integer, | |
Rational, | |
Proc, | |
Queue, | |
Random, | |
Range, | |
Regexp, | |
RubyVM, | |
String, | |
Struct, | |
Symbol, | |
Thread, | |
SizedQueue, | |
ThreadGroup, | |
Time, | |
TracePoint, | |
TrueClass, | |
UnboundMethod, | |
] | |
searchee_method = ARGV[0] | |
classes_defines_this = [] | |
classes.each do |c| | |
methods = [c.methods(false), c.instance_methods(false)].flatten.map(&:to_s) | |
classes_defines_this << c if methods.include?(searchee_method) | |
end | |
if classes_defines_this.count > 0 | |
puts "The method \"#{searchee_method}\" is defined at #{classes_defines_this.join(", ")}" | |
else | |
puts "No class defines the method \"#{searchee_method}\"." | |
exit 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment