Created
May 14, 2014 13:04
-
-
Save murajun1978/88169357ed5bcaa4f4fe to your computer and use it in GitHub Desktop.
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
| module Foo | |
| def foo | |
| :foo | |
| end | |
| end | |
| class Bar | |
| include Foo | |
| def bar | |
| :bar | |
| end | |
| end | |
| class Buz | |
| extend Foo | |
| def buz | |
| :buz | |
| end | |
| end | |
| # Bar Instance methods | |
| p Bar.new.class.instance_methods.grep(/bar|foo/) # => [:bar, :foo] | |
| # Buz Instance methods | |
| p Buz.new.class.instance_methods.grep(/buz|foo/) # => [:buz] | |
| # Buz Class methods | |
| p Buz.new.class.methods.grep(/foo|buz/) # => [:foo] | |
| # a list of modules and classes | |
| p Bar.ancestors # => [Bar, Foo, Object, Kernel, BasicObject] | |
| # singleton methods | |
| p Bar.singleton_methods # => [] | |
| # a list of modules and classes | |
| p Buz.ancestors # => [Buz, Object, Kernel, BasicObject] | |
| # singleton methods | |
| p Buz.singleton_methods # => [:foo] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment