Last active
October 25, 2019 13:32
-
-
Save x-yuri/f95e4730a7a4787d4861eb4d30e1e45a to your computer and use it in GitHub Desktop.
ruby: list methods (group by class/module)
This file contains hidden or 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
| class A | |
| def im; end | |
| def self.cm; end | |
| end | |
| def superclasses c | |
| r = [] | |
| while c.superclass | |
| r << c.superclass | |
| c = c.superclass | |
| end | |
| r | |
| end | |
| def included_modules c | |
| if c.superclass | |
| c.included_modules - c.superclass.included_modules | |
| else | |
| c.included_modules | |
| end | |
| end | |
| c = A | |
| puts "#{c}: superclasses: " + superclasses(c).join(', ') | |
| puts "#{c}: ancestors: " + c.ancestors.join(', ') | |
| ([c] + superclasses(c)).each do |c| | |
| puts c.name + ': included_modules: ' + included_modules(c).join(', ') | |
| end | |
| puts 'instance methods:' | |
| c.ancestors.each do |c| | |
| puts " #{c.name}:" | |
| c.instance_methods(false).sort.each do |m| | |
| puts " #{m}" | |
| end | |
| end | |
| puts 'class methods:' | |
| puts " #{c.name}:" | |
| c.methods(false).sort.each do |m| | |
| puts " #{m}" | |
| end | |
| c.class.ancestors.each do |c| | |
| puts " #{c.name}:" | |
| c.instance_methods(false).sort.each do |m| | |
| puts " #{m}" | |
| end | |
| end |
This file contains hidden or 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
| A: superclasses: Object, BasicObject | |
| A: ancestors: A, Object, Kernel, BasicObject | |
| A: included_modules: | |
| Object: included_modules: Kernel | |
| BasicObject: included_modules: | |
| instance methods: | |
| A: | |
| im | |
| Object: | |
| Kernel: | |
| !~ | |
| <=> | |
| === | |
| =~ | |
| class | |
| clone | |
| define_singleton_method | |
| display | |
| dup | |
| enum_for | |
| eql? | |
| extend | |
| freeze | |
| frozen? | |
| hash | |
| inspect | |
| instance_of? | |
| instance_variable_defined? | |
| instance_variable_get | |
| instance_variable_set | |
| instance_variables | |
| is_a? | |
| itself | |
| kind_of? | |
| method | |
| methods | |
| nil? | |
| object_id | |
| private_methods | |
| protected_methods | |
| public_method | |
| public_methods | |
| public_send | |
| remove_instance_variable | |
| respond_to? | |
| send | |
| singleton_class | |
| singleton_method | |
| singleton_methods | |
| taint | |
| tainted? | |
| tap | |
| then | |
| to_enum | |
| to_s | |
| trust | |
| untaint | |
| untrust | |
| untrusted? | |
| yield_self | |
| BasicObject: | |
| ! | |
| != | |
| == | |
| __id__ | |
| __send__ | |
| equal? | |
| instance_eval | |
| instance_exec | |
| class methods: | |
| A: | |
| cm | |
| Class: | |
| allocate | |
| new | |
| superclass | |
| Module: | |
| < | |
| <= | |
| <=> | |
| == | |
| === | |
| > | |
| >= | |
| alias_method | |
| ancestors | |
| attr | |
| attr_accessor | |
| attr_reader | |
| attr_writer | |
| autoload | |
| autoload? | |
| class_eval | |
| class_exec | |
| class_variable_defined? | |
| class_variable_get | |
| class_variable_set | |
| class_variables | |
| const_defined? | |
| const_get | |
| const_missing | |
| const_set | |
| constants | |
| define_method | |
| deprecate_constant | |
| freeze | |
| include | |
| include? | |
| included_modules | |
| inspect | |
| instance_method | |
| instance_methods | |
| method_defined? | |
| module_eval | |
| module_exec | |
| name | |
| prepend | |
| private_class_method | |
| private_constant | |
| private_instance_methods | |
| private_method_defined? | |
| protected_instance_methods | |
| protected_method_defined? | |
| public_class_method | |
| public_constant | |
| public_instance_method | |
| public_instance_methods | |
| public_method_defined? | |
| remove_class_variable | |
| remove_method | |
| singleton_class? | |
| to_s | |
| undef_method | |
| Object: | |
| Kernel: | |
| !~ | |
| <=> | |
| === | |
| =~ | |
| class | |
| clone | |
| define_singleton_method | |
| display | |
| dup | |
| enum_for | |
| eql? | |
| extend | |
| freeze | |
| frozen? | |
| hash | |
| inspect | |
| instance_of? | |
| instance_variable_defined? | |
| instance_variable_get | |
| instance_variable_set | |
| instance_variables | |
| is_a? | |
| itself | |
| kind_of? | |
| method | |
| methods | |
| nil? | |
| object_id | |
| private_methods | |
| protected_methods | |
| public_method | |
| public_methods | |
| public_send | |
| remove_instance_variable | |
| respond_to? | |
| send | |
| singleton_class | |
| singleton_method | |
| singleton_methods | |
| taint | |
| tainted? | |
| tap | |
| then | |
| to_enum | |
| to_s | |
| trust | |
| untaint | |
| untrust | |
| untrusted? | |
| yield_self | |
| BasicObject: | |
| ! | |
| != | |
| == | |
| __id__ | |
| __send__ | |
| equal? | |
| instance_eval | |
| instance_exec |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment