Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dump ancestors' methods by ls command #234

Merged
merged 1 commit into from
May 8, 2021

Conversation

pocke
Copy link
Member

@pocke pocke commented May 2, 2021

ls command has been implemented by #203.
Pry's ls displays ancestors' methods, but IRB doesn't.

This pull request makes ls command display ancestors' methods.

Example

With the following definition:

class P
  def p() end
end

class C < P
  def m1() end
end

module M
  def m2() end
end

module M2
  include M
  def m3() end
end

obj = C.new
obj.extend M2
def obj.m4() end

before

irb(main):043:0> ls obj
C.methods: m4
C#methods: m1

after

irb(main):026:0> ls obj
M#methods: m2
M2#methods: m3
C.methods: m4
P#methods: p
C#methods: m1

Note that it omits Object and Object's ancestors because we can assure the argument inherits Object class easily. Pry has the same behavior.

@aycabta aycabta merged commit 5f63a02 into ruby:master May 8, 2021
@aycabta
Copy link
Member

aycabta commented May 8, 2021

Good catch!

@pocke pocke deleted the Dump_ancestors__methods_by_ls_command branch May 8, 2021 05:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants