Reputation: 870
is that a way where i can search the API documentation for a method from the rails console? E.g. the method arguments, returning object, etc
Upvotes: 1
Views: 466
Reputation: 52488
From irb (it might also work in rails console), you can do
require 'pry'
pry
require 'pry-doc'
? File.link # Shows documentation for File.link method, replace
# with whatever method you want
From: file.c (C Method):
Owner: #<Class:File>
Visibility: public
Signature: link(arg1, arg2)
Number of lines: 20
Creates a new name for an existing file using a hard link. Will not
overwrite new_name if it already exists (raising a subclass
of SystemCallError). Not available on all platforms.
File.link("testfile", ".testfile") #=> 0
IO.readlines(".testfile")[0] #=> "This is line one\n"
static VALUE
rb_file_s_link(VALUE klass, VALUE from, VALUE to)
{
FilePathValue(from);
FilePathValue(to);
from = rb_str_encode_ospath(from);
to = rb_str_encode_ospath(to);
if (link(StringValueCStr(from), StringValueCStr(to)) < 0) {
sys_fail2(from, to);
}
return INT2FIX(0);
}
Note you'll need pry and pry-doc installed:
gem install pry
gem install pry-doc
Upvotes: 1
Reputation: 870
It is not rails console, but it is "ri" in console. This is what i am looking for.
Upvotes: 0