I started learning ruby recently (yesterday). I am using the
interactive irb to try out the various ruby features. But I am
very much missing the help feature which I was so used to
in the python's interactive environment, the __doc__ feature,
etc. (I hope at least some of you have used Python before
and know what I mean).
I am sure there must be something similar accessible from
within irb, but I don't know where to look. It would be very
helpful if you could please point me to the right direction.
I believe you can use `help`. For example: help puts
--Jeremy
···
On Dec 27, 2007 8:35 AM, Santanu <thisissantanu@gmail.com> wrote:
Hello Everybody,
I started learning ruby recently (yesterday). I am using the
interactive irb to try out the various ruby features. But I am
very much missing the help feature which I was so used to
in the python's interactive environment, the __doc__ feature,
etc. (I hope at least some of you have used Python before
and know what I mean).
I am sure there must be something similar accessible from
within irb, but I don't know where to look. It would be very
helpful if you could please point me to the right direction.
First of all, thanks for your response.
Yes, I did try things like 'help puts', but all I get are these error
messages:
···
On Dec 27, 6:56 pm, Jeremy McAnally <jeremymcana...@gmail.com> wrote:
I believe you can use `help`. For example: help puts
-------------------------------------------
irb(main):032:0> help puts
No ri documentation found in:
Was rdoc run to create documentation?
Errno::ENOENT: No such file or directory - (null)
from /usr/lib/ruby/1.8/rdoc/usage.rb:100:in `initialize'
from /usr/lib/ruby/1.8/rdoc/usage.rb:100:in `open'
from /usr/lib/ruby/1.8/rdoc/usage.rb:100:in `usage_no_exit'
from /usr/lib/ruby/1.8/rdoc/usage.rb:93:in `usage'
from /usr/lib/ruby/1.8/rdoc/ri/ri_driver.rb:39:in
`report_missing_documentation'
from /usr/lib/ruby/1.8/rdoc/ri/ri_driver.rb:25:in `initialize'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require'
from (eval):3:in `help'
from (irb):32
from (null):0
irb(main):033:0>
-------------------------------------
I use Ubuntu 7.10, and I have already installed rdoc. I don't
understand
the error message much but it seems I have to do something else to
make the help command work. Do I have to install ruby source and run
rdoc through them?
Errno::ENOENT: No such file or directory - /cdesc-::.yaml
from /opt/local/lib/ruby/1.8/rdoc/ri/ri_reader.rb:54:in `initialize'
from /opt/local/lib/ruby/1.8/rdoc/ri/ri_reader.rb:54:in `open'
from /opt/local/lib/ruby/1.8/rdoc/ri/ri_reader.rb:54:in `get_class'
from /opt/local/lib/ruby/1.8/rdoc/ri/ri_reader.rb:52:in `each'
---------------------------------------------------------- Class: String
A +String+ object holds and manipulates an arbitrary sequence of
bytes, typically representing characters. String objects may be
created using +String::new+ or as literals.
Because of aliasing issues, users of strings should be aware of the
methods that modify the contents of a +String+ object. Typically,
methods with names ending in ``!'' modify their receiver, while
those without a ``!'' return a new +String+. However, there are
exceptions, such as +String#=+.
···
------------------------------------------------------------------------
Enhance the String class with a XML escaped character version of
to_s.
------------------------------------------------------------------------
Enhance the String class with a XML escaped character version of
to_s.
------------------------------------------------------------------------
Enhance the String class with a XML escaped character version of
to_s.
I don't know why that error is there...but oh well.
--Jeremy
On Dec 27, 2007 9:24 AM, Santanu <thisissantanu@gmail.com> wrote:
On Dec 27, 6:56 pm, Jeremy McAnally <jeremymcana...@gmail.com> wrote:
> I believe you can use `help`. For example: help puts
>
First of all, thanks for your response.
Yes, I did try things like 'help puts', but all I get are these error
messages:
-------------------------------------------
irb(main):032:0> help puts
No ri documentation found in:
Was rdoc run to create documentation?
Errno::ENOENT: No such file or directory - (null)
from /usr/lib/ruby/1.8/rdoc/usage.rb:100:in `initialize'
from /usr/lib/ruby/1.8/rdoc/usage.rb:100:in `open'
from /usr/lib/ruby/1.8/rdoc/usage.rb:100:in `usage_no_exit'
from /usr/lib/ruby/1.8/rdoc/usage.rb:93:in `usage'
from /usr/lib/ruby/1.8/rdoc/ri/ri_driver.rb:39:in
`report_missing_documentation'
from /usr/lib/ruby/1.8/rdoc/ri/ri_driver.rb:25:in `initialize'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require'
from (eval):3:in `help'
from (irb):32
from (null):0
irb(main):033:0>
-------------------------------------
I use Ubuntu 7.10, and I have already installed rdoc. I don't
understand
the error message much but it seems I have to do something else to
make the help command work. Do I have to install ruby source and run
rdoc through them?
Maybe there are ri / ruby-doc / ruby-dev packages that provide the
docs? You shouldn't have to build from source...I can't imagine the
maintainers of Ubuntu would leave it out altogether. But I could be
wrong...in which case here is a guide for building ruby from source on
ubuntu (it's easy http://www.rubywizards.com/viewtopic.php?pid=19
Regards,
Jordan
···
On Dec 27, 8:22 am, Santanu <thisissant...@gmail.com> wrote:
On Dec 27, 6:56 pm, Jeremy McAnally <jeremymcana...@gmail.com> wrote:
> I believe you can use `help`. For example: help puts
First of all, thanks for your response.
Yes, I did try things like 'help puts', but all I get are these error
messages:
-------------------------------------------
irb(main):032:0> help puts
No ri documentation found in:
Was rdoc run to create documentation?
Errno::ENOENT: No such file or directory - (null)
from /usr/lib/ruby/1.8/rdoc/usage.rb:100:in `initialize'
from /usr/lib/ruby/1.8/rdoc/usage.rb:100:in `open'
from /usr/lib/ruby/1.8/rdoc/usage.rb:100:in `usage_no_exit'
from /usr/lib/ruby/1.8/rdoc/usage.rb:93:in `usage'
from /usr/lib/ruby/1.8/rdoc/ri/ri_driver.rb:39:in
`report_missing_documentation'
from /usr/lib/ruby/1.8/rdoc/ri/ri_driver.rb:25:in `initialize'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require'
from (eval):3:in `help'
from (irb):32
from (null):0
irb(main):033:0>
-------------------------------------
I use Ubuntu 7.10, and I have already installed rdoc. I don't
understand
the error message much but it seems I have to do something else to
make the help command work. Do I have to install ruby source and run
rdoc through them?
Errno::ENOENT: No such file or directory - /cdesc-::.yaml
from /opt/local/lib/ruby/1.8/rdoc/ri/ri_reader.rb:54:in `initialize'
from /opt/local/lib/ruby/1.8/rdoc/ri/ri_reader.rb:54:in `open'
from /opt/local/lib/ruby/1.8/rdoc/ri/ri_reader.rb:54:in `get_class'
from /opt/local/lib/ruby/1.8/rdoc/ri/ri_reader.rb:52:in `each'
Hi Jeremy,
There are no keywords here; #help is just a method that expects a
string, and #puts is returning nil. Try:
>> help 'puts'
Alternatively, just:
$ ri puts
on the command line.
Regards,
George.
···
On Dec 28, 2007 1:40 AM, Jeremy McAnally <jeremymcanally@gmail.com> wrote:
Thanks. Just now I compiled ruby-1.9 and installed it with docs. Now,
at least
help command at the irb prompt provides some help. 'help puts' is
still
problematic though, but things like 'help Array' does give some
understandable
result.
However, I am still searching for the exact syntax for asking for help
on say, Array.collect, etc. at the irb prompt. Any pointers?
Regards,
Santanu
···
On Dec 27, 8:05 pm, MonkeeSage <MonkeeS...@gmail.com> wrote:
On Dec 27, 8:22 am, Santanu <thisissant...@gmail.com> wrote:
> On Dec 27, 6:56 pm, Jeremy McAnally <jeremymcana...@gmail.com> wrote:
> > I believe you can use `help`. For example: help puts
> Yes, I did try things like 'help puts', but all I get are these error
> messages:
> -------------------------------------------
> irb(main):032:0> help puts
> No ri documentation found in:
> Was rdoc run to create documentation?
> .........
> -------------------------------------
> I use Ubuntu 7.10, and I have already installed rdoc. I don't
> understand
> the error message much but it seems I have to do something else to
> make the help command work. Do I have to install ruby source and run
> rdoc through them?
Maybe there are ri / ruby-doc / ruby-dev packages that provide the
docs? You shouldn't have to build from source...I can't imagine the
maintainers of Ubuntu would leave it out altogether. But I could be
wrong...in which case here is a guide for building ruby from source on
ubuntu (it's easy http://www.rubywizards.com/viewtopic.php?pid=19
I'm not sure which package they're in, but for the record, the
Ubuntu/Debian packages do include rdocs for standard libraries in
/usr/share/ri
Daniel Brumbaugh Keeney
···
On Dec 27, 2007 9:09 AM, MonkeeSage wrote:
Maybe there are ri / ruby-doc / ruby-dev packages that provide the
docs? You shouldn't have to build from source...I can't imagine the
maintainers of Ubuntu would leave it out altogether. But I could be
wrong...in which case here is a guide for building ruby from source on
ubuntu (it's easy http://www.rubywizards.com/viewtopic.php?pid=19
On Dec 27, 2007 11:24 AM, Santanu <thisissantanu@gmail.com> wrote:
Thanks. Just now I compiled ruby-1.9 and installed it with docs. Now,
at least
help command at the irb prompt provides some help. 'help puts' is
still
problematic though, but things like 'help Array' does give some
understandable
result.
However, I am still searching for the exact syntax for asking for help
on say, Array.collect, etc. at the irb prompt. Any pointers?
Thanks. That solved my last problem with irb. After I compiled
and installed ruby from source. I was wondering why I could
not do things like 'help Array.collect'. Now I think I get it.
Yeah... help 'Array.collect' works now.
Thanks again.
Regards,
Santanu
···
On Dec 27, 8:58 pm, George <george.og...@gmail.com> wrote:
#help is just a method that expects a
string, and #puts is returning nil. Try:
# help about the instance method "reverse_each"
# (found in class Array).
help "send"
# if multiple methods match, it will give a list with
# the qualifying namespaces. note that symbols can be
# used rather than strings as the argument to #help
help :index
# instance method "each_slice" of Enumerable module.
# note the string use, so that ruby doesn't try to
# call each_slice on a Symbol object (:Enumerable)
# note also that the "#" could be spelled as "."
# and ri doesn't care; but "#" is the usual spelling
# you'll see round here when speaking about methods
help "Enumerable#each_slice"
# help about an instance method of a module nested
# in a class. note the string again. like in ruby
# itself, access to a class/module-level constant
# (in this case a module) is done with "::". but
# for instance-level, we use "#" / "." (only the
"." is valid in actual ruby code)
help "OptionParser::Completion#complete"
# help about a class method of a class nested
# in a class. note again the syntax difference,
# "#" / "." vs. "::".
help "OptionParser::Switch::guess"
Ps. The examples I used aren't the most enlightening, I just opened a
random stdlib file and looked at the first instances of what I was
trying to exemplify; so don't think that all (or even most) of the
ruby documentation is as cryptic or unhelpful as, for example, the
output from ` help "OptionParser::Switch::guess"` heh!
Regards,
Jordan
···
On Dec 27, 10:23 am, Santanu <thisissant...@gmail.com> wrote:
On Dec 27, 8:05 pm, MonkeeSage <MonkeeS...@gmail.com> wrote:
> On Dec 27, 8:22 am, Santanu <thisissant...@gmail.com> wrote:
> > On Dec 27, 6:56 pm, Jeremy McAnally <jeremymcana...@gmail.com> wrote:
> > > I believe you can use `help`. For example: help puts
> > Yes, I did try things like 'help puts', but all I get are these error
> > messages:
> > -------------------------------------------
> > irb(main):032:0> help puts
> > No ri documentation found in:
> > Was rdoc run to create documentation?
> > .........
> > -------------------------------------
> > I use Ubuntu 7.10, and I have already installed rdoc. I don't
> > understand
> > the error message much but it seems I have to do something else to
> > make the help command work. Do I have to install ruby source and run
> > rdoc through them?
> Maybe there are ri / ruby-doc / ruby-dev packages that provide the
> docs? You shouldn't have to build from source...I can't imagine the
> maintainers of Ubuntu would leave it out altogether. But I could be
> wrong...in which case here is a guide for building ruby from source on
> ubuntu (it's easy http://www.rubywizards.com/viewtopic.php?pid=19
Thanks. Just now I compiled ruby-1.9 and installed it with docs. Now,
at least
help command at the irb prompt provides some help. 'help puts' is
still
problematic though, but things like 'help Array' does give some
understandable
result.
However, I am still searching for the exact syntax for asking for help
on say, Array.collect, etc. at the irb prompt. Any pointers?
Thanks. That works. By the way, "help 'Array.collect'" works too.
Are Array.collect and Array#collect equivalent or is this about
class method vs. instance method. (I don't know ruby that much
yet. Just started learning it from "Ruby By Example" yesterday).
Regards,
Santanu
···
On Dec 27, 9:35 pm, Stephen Duncan <stephen.dun...@gmail.com> wrote:
On Dec 27, 2007 11:24 AM, Santanu <thisissant...@gmail.com> wrote:
> However, I am still searching for the exact syntax for asking for help
> on say, Array.collect, etc. at the irb prompt. Any pointers?
"#" and "." are equivalent, "::" is for class methods (and other
class / module level constants). I started writing my last message
about twenty minutes ago, then my cat got into a bag of wrapping-paper
from Christmas and messed up the living room (that's a bad kitty!), so
I got side-tracked...but I basically tried to demonstrate this
difference with the last two calls to #help in my last message. See
also the source of optparse.rb to see what my examples refer to about
"class nested in a class" and so forth: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8/lib/optparse.rb
Regards,
Jordan
···
On Dec 27, 10:49 am, Santanu <thisissant...@gmail.com> wrote:
On Dec 27, 9:35 pm, Stephen Duncan <stephen.dun...@gmail.com> wrote:
> On Dec 27, 2007 11:24 AM, Santanu <thisissant...@gmail.com> wrote:
> > However, I am still searching for the exact syntax for asking for help
> > on say, Array.collect, etc. at the irb prompt. Any pointers?
> >> help 'Array#collect'
Thanks. That works. By the way, "help 'Array.collect'" works too.
Are Array.collect and Array#collect equivalent or is this about
class method vs. instance method. (I don't know ruby that much
yet. Just started learning it from "Ruby By Example" yesterday).
I started writing my last message
about twenty minutes ago, then my cat got into a bag of wrapping-paper
from Christmas and messed up the living room (that's a bad kitty!) so
I got side-tracked...
I know what you mean. I have a puppy.
but I basically tried to demonstrate this
difference with the last two calls to #help in my last message. See
also the source of optparse.rb to see what my examples refer to about
"class nested in a class" and so forth:http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8/lib/optparse.rb
Will do. Thanks for your last post. That cleared up quite a few things
about
getting help at the irb prompt.
Thanks again.
Regards,
Santanu
···
On Dec 27, 10:18 pm, MonkeeSage <MonkeeS...@gmail.com> wrote:
you might also just consider having another terminal window open and use it for running ri.
this can be far more convenient (IMHO) than the clutter in irb.