3

I often forget the syntax for the newer keyword arguments when I want to scoop up extra arguments with double splats and the like. The online Ruby docs has articles such as http://ruby-doc.org/core-2.1.0/doc/syntax/methods_rdoc.html and http://ruby-doc.org/core-2.0.0/doc/syntax/calling_methods_rdoc.html, but how could I access this info via ri?

Or is ri (as implied by the interactive mode's question "Enter the method name you want to look up") the only sort of thing it will find?

halfer
  • 19,824
  • 17
  • 99
  • 186
ian
  • 12,003
  • 9
  • 51
  • 107

1 Answers1

3

You can access the static pages via:

$ ri ruby:syntax/methods

Output:

= Methods

Methods implement the functionality of your program.  Here is a simple method
definition:

  def one_plus_one
    1 + 1
  end

A method definition consists of the def keyword, a method name, the body of
the method, return value and the end keyword.  When called the method will
execute the body of the method.  This method returns 2.

This section only covers defining methods.  See also the {syntax documentation
on calling methods}[rdoc-ref:syntax/calling_methods.rdoc].

[...]
Stefan
  • 109,145
  • 14
  • 143
  • 218
  • 2
    Ah! `ri ruby:syntax` brings up a kind of menu page too, in case I forget the `methods` part (I will forget:). Very nice, thanks. – ian Aug 16 '17 at 13:40
  • Thanks for this. I've been scouring over various ri/rdoc documentations/tutorial/help-pages and I don't think I've seen this (i.e. use `ruby:` prefix) mentioned anywhere. – doubleDown Aug 17 '17 at 15:12
  • 2
    @doubleDown the prefix selects an rdoc data store which is usually a gem. The documentation for [`RDoc::Store#source`](http://ruby-doc.org/stdlib-2.4.1/libdoc/rdoc/rdoc/RDoc/Store.html#method-i-source) mentions that it can also be "home", "site" and "ruby". – Stefan Aug 17 '17 at 15:36
  • 1
    @iain there's also `ri ruby:` which will list all ruby core pages. – Stefan Aug 17 '17 at 15:37