pryについて

今まで

  • rubyのドキュメント( http://ref.xaio.jp/ruby )とかでそれっぽいメソッドを探していた。しかもこのドキュメントよく見たら、1.9くらいだった笑
  • 検証したいときは、適当なとこにbinding.pry書いて、無理やりインタープリターを起動して検証したりしていた。

pryのちゃんとした使い方を知って

MacBook-Pro:~ hogehoge$ pry
[1] pry(main)> cd String
[2] pry(String):1> ls
String.methods: try_convert
String#methods:
  %    []           casecmp?    concat     each_codepoint  getbyte   length   ord           rstrip       slice        succ       to_str               unpack1
  *    []=          center      count      each_line       gsub      lines    partition     rstrip!      slice!       succ! 
……
……
……
……
locals: _  __  _dir_  _ex_  _file_  _in_  _out_  _pry_
[3] pry(String):1> show-doc upcase
From: string.c (C Method):
Owner: String
Visibility: public
Signature: upcase(*arg1)
Number of lines: 6

Returns a copy of str with all lowercase letters replaced with their
uppercase counterparts.

See String#downcase for meaning of options and use with different encodings.

   "hEllO".upcase   #=> "HELLO"
[4] pry(String):1> hoge = "hoge";
[5] pry(String):1> hoge.upcase!
=> "HOGE"
[6] pry(String):1> hoge
=> "HOGE"

みたいな感じで単純にメソッド探して、確認できるみたいな便利なことができると知りました。無知ですいませんでした。

[5] pry(main)> help

とやると他にも便利なメソッドがたくさんありそうです。

今流行りのdockerで使うには??

$ docker-compose run --service-ports hoge

Run command with the service’s ports enabled and mapped to the host.

だそうです。

所感

ここら辺のserviceportとかとか、pryとかirbがどんな感じで動いてるかとかあまりわからないので、勉強しないと。

参考リンク

qiita.com