From e9f4f64eb0f0f7c3a84f08d67b92523019937827 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Thu, 28 Jan 2016 21:56:11 -0600 Subject: [PATCH] Add Show Public Methods With Pry as a ruby til --- README.md | 1 + ruby/show-public-methods-with-pry.md | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 ruby/show-public-methods-with-pry.md diff --git a/README.md b/README.md index e2809b4..e4dcdf9 100644 --- a/README.md +++ b/README.md @@ -238,6 +238,7 @@ _310 TILs and counting..._ - [Returning With Sequel](ruby/returning-with-sequel.md) - [Safe Navigation Operator](ruby/safe-navigation-operator.md) - [Set RVM Default Ruby](ruby/set-rvm-default-ruby.md) +- [Show Public Methods With Pry](ruby/show-public-methods-with-pry.md) - [Squeeze Out The Extra Space](ruby/squeeze-out-the-extra-space.md) - [Summing Collections](ruby/summing-collections.md) - [Uncaught Exceptions In Pry](ruby/uncaught-exceptions-in-pry.md) diff --git a/ruby/show-public-methods-with-pry.md b/ruby/show-public-methods-with-pry.md new file mode 100644 index 0000000..e50f3de --- /dev/null +++ b/ruby/show-public-methods-with-pry.md @@ -0,0 +1,17 @@ +# Show Public Methods With Pry + +Open up a [`pry`](https://github.com/pry/pry) session and use the `-m` flag +with the `ls` command to show just the public methods for an object. + +```ruby +> ls -m :hello +Comparable#methods: < <= > >= between? +Symbol#methods: + <=> as_json empty? length slice to_sym + == capitalize encoding match succ upcase + === casecmp id2name next swapcase + =~ downcase inspect pretty_print_cycle to_proc + [] duplicable? intern size to_s +``` + +[source](https://github.com/pry/pry/wiki/State-navigation#Ls)