LoginSignup
1
1

More than 3 years have passed since last update.

binding.pryで grepしたい

Posted at

結論から言うと多分できないのですが、同じようなことをする方法はあります。

「pry grep」とかでググっても出て来なかったので書きました。

(何らかの出力結果) | grep hoge

ってのはコマンドライン上ではできるのですが、pry上で
出来なくて困っていました。

解決策

(出力結果).select{ |item| item.to_s.match('絞り込みたいワード') }

これでいけます。

grepを使わなくてもRubyのメソッドでどうにでもなりました。

具体例

ex.)
binding.pryが止まっているところで、使えるメソッドの中で、'current'と名のつくメソッドだけが知りたい!

methods.select{ |item| item.to_s.match('current') }

matchには正規表現も使えるので、使いこなせるともっと便利ですね

1
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1