Ruby 在控制台中,是否可以通过任何方式获取特定方法的功能信息?
假设我使用gemRuby 在控制台中,是否可以通过任何方式获取特定方法的功能信息?,ruby,command-line,console,gem,Ruby,Command Line,Console,Gem,假设我使用gemcsv 通过控制台中的以下内容,我可以获得所有实例方法的列表: require "csv" csv = CSV.open(FILE_NAME, "a+") csv.methods 我现在在列表中找到的一种方法是,例如,first 我可以从命令行获取有关此方法的信息吗?(是的,我知道我可以用谷歌搜索文档。)(IRB替代方案)支持: $pry [1] 撬(主)>需要“csv” #=>正确 [2] 撬(主)>csv=csv.新(“”) #=>(IRB替代方案)支持: $pry [1]
csv
通过控制台中的以下内容,我可以获得所有实例方法的列表:
require "csv"
csv = CSV.open(FILE_NAME, "a+")
csv.methods
我现在在列表中找到的一种方法是,例如,first
我可以从命令行获取有关此方法的信息吗?(是的,我知道我可以用谷歌搜索文档。)(IRB替代方案)支持:
$pry
[1] 撬(主)>需要“csv”
#=>正确
[2] 撬(主)>csv=csv.新(“”)
#=>(IRB替代方案)支持:
$pry
[1] 撬(主)>需要“csv”
#=>正确
[2] 撬(主)>csv=csv.新(“”)
#=>最简单的方法可能是ri
$ ri 'CSV#first'
= CSV#first
(from ruby core)
=== Implementation from Enumerable
------------------------------------------------------------------------------
enum.first -> obj or nil
enum.first(n) -> an_array
------------------------------------------------------------------------------
Returns the first element, or the first n elements, of the enumerable. If the
enumerable is empty, the first form returns nil, and the second form returns
an empty array.
%w[foo bar baz].first #=> "foo"
%w[foo bar baz].first(2) #=> ["foo", "bar"]
%w[foo bar baz].first(10) #=> ["foo", "bar", "baz"]
[].first #=> nil
您可能需要首先安装文档,如中所述:最简单的方法可能是ri
$ ri 'CSV#first'
= CSV#first
(from ruby core)
=== Implementation from Enumerable
------------------------------------------------------------------------------
enum.first -> obj or nil
enum.first(n) -> an_array
------------------------------------------------------------------------------
Returns the first element, or the first n elements, of the enumerable. If the
enumerable is empty, the first form returns nil, and the second form returns
an empty array.
%w[foo bar baz].first #=> "foo"
%w[foo bar baz].first(2) #=> ["foo", "bar"]
%w[foo bar baz].first(10) #=> ["foo", "bar", "baz"]
[].first #=> nil
您可能需要首先安装文档,如中所述:这可能是因为您必须安装Pry。值得注意的是,这可能是因为您必须安装Pry。值得注意的是。