sub*_*iet 9 ruby console grep ruby-on-rails
在shell中,我可以做到
$ cat name_of_file_with_a_lot_of_text | grep "What I am looking for"
Run Code Online (Sandbox Code Playgroud)
在Rails控制台内部,我可以实现类似的功能,例如当我运行命令并且输出很大时,尤其是数据库查询.
我知道将它输出为YAML,但这不是我想要的.
谢谢.
Mar*_*her 21
是的你可以.该方法称为gr ...等待它... ep.Ruby的grep
作品上String
,Array
和许多其他内置对象.例如,要获取数字的所有to_xxx
方法,只需执行以下操作:
1.methods.grep(/to_/)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5114 次 |
最近记录: |