:note

Pry で what_methods をつかう

irb のかわりに Pryを使う。

そしてrubyでアレなんてメソッドだっけ?を解決する what_methods を使ってみた

gem install pry
gem install what_methods

~/.pryrcを作成し

require "what_methods"

使い方

milligramme: ~ ♣  pry
[1] pry(main)> (0..3).what? [0,1,2,3]
[1] pry(#<Range>)> exit
0..3.to_a == [0, 1, 2, 3]
0..3.entries == [0, 1, 2, 3]
0..3.sort == [0, 1, 2, 3]
=> [:to_a, :entries, :sort]
[2] pry(main)> ["a",nil,"b",nil].what? ["a","b"]
[1] pry(#<Array>)> exit
["a", nil, "b", nil].compact == ["a", "b"]
["a", nil, "b", nil].compact! == ["a", "b"]
=> [:compact, :compact!]
[3] pry(main)> " aaa ".what? "aaa"
[1] pry(" aaa ")> exit
" aaa ".strip == "aaa"
" aaa ".strip! == "aaa"
=> [:strip, :strip!]

一度、pry(main) から pry(#)> となって exit してからでないと結果がでなかったのだけどなにか設定の仕方があるんだろうか?

irb + what_methods だとすぐ結果がでる

ruby-1.9.3-p0 :001 > (0..3).what? [0,1,2,3]
0..3.to_a == [0, 1, 2, 3]
0..3.entries == [0, 1, 2, 3]
0..3.sort == [0, 1, 2, 3]
 => [:to_a, :entries, :sort] 

参考にした

 
comments powered by Disqus
back to top