# To get help from inside irb console

**URL:** <https://www.ruby-forum.com/t/to-get-help-from-inside-irb-console/155380>\
**Category:** Ruby\
**Created:** [December 11, 2008, 7:48am UTC](https://www.ruby-forum.com/t/to-get-help-from-inside-irb-console/155380 "2008-12-11T07:48:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [December 11, 2008, 7:48am UTC](https://www.ruby-forum.com/t/to-get-help-from-inside-irb-console/155380/1 "2008-12-11T07:48:05Z")

</div>

Hi  
How to get help from inside irb console I would like to know what the  
following is

OpenSSL::Random.random\_bytes

Thanks in advance  
Sijo

---

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [December 11, 2008, 10:17am UTC](https://www.ruby-forum.com/t/to-get-help-from-inside-irb-console/155380/2 "2008-12-11T10:17:48Z")

</div>

Sijo Kg wrote:

> Hi  
> How to get help from inside irb console I would like to know what the  
> following is
> 
> OpenSSL::Random.random\_bytes
> 
> Thanks in advance  
> Sijo

Unfortunately the OpenSSL Ruby extensions are not well documented,  
especially the C native parts. ri seems to know nothing about them. I  
usually dive into the C source, and/or guess based on the OpenSSL C API.

You’ll get some documentation here:  
[http://www.ruby-doc.org/stdlib/](http://www.ruby-doc.org/stdlib/)

If you click on the ‘openssl’ link on the left, and then on ‘random\_key’  
in the top right, then on the ‘source’ link for random\_key, you’ll get  
an example which shows random\_bytes in action:

```
  def random_key
    str = OpenSSL::Random.random_bytes(self.key_len)
    self.key = str
    return str
  end

```

But if you want to know exactly what random\_bytes does, you’ll need to  
look at OpenSSL’s own documentation. man -k may help you search for it.  
In this case, “man RAND\_bytes” looks like the one.

See also “man 3ssl ssl” or “man 3 ssl”, also at  
[http://www.openssl.org/docs/ssl/ssl.html](http://www.openssl.org/docs/ssl/ssl.html)

As for getting ri help from within irb, you could always do

system “ri String”

or write something in .irbrc which does this. Google for “irbrc” or “ri  
in irbrc” for some ideas.

Often all I do is something like this:

```
str = "abc"
str.methods - Object.instance_methods - Enumerable.instance_methods

```

---

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [December 11, 2008, 11:45am UTC](https://www.ruby-forum.com/t/to-get-help-from-inside-irb-console/155380/3 "2008-12-11T11:45:16Z")

</div>

Thanks for your reply…I saw this also  
irb\_help  
For that what I did is  
require ‘openssl’  
irb\_help OpenSSL::Random.random\_bytes

But this gives me error ArgumentError: wrong number of arguments (0 for  
1)  
But when I did like  
irb\_help OpenSSL::Random.random\_bytes(2)  
it gives  
Nothing known about ï¿½ï¿½

```
What is this irb_help actually?

```

Sijo

---

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [December 11, 2008, 12:14pm UTC](https://www.ruby-forum.com/t/to-get-help-from-inside-irb-console/155380/4 "2008-12-11T12:14:04Z")

</div>

Sijo Kg wrote:

> For that what I did is  
> require ‘openssl’  
> irb\_help OpenSSL::Random.random\_bytes

Interesting, irb\_help is new to me.

> But this gives me error ArgumentError: wrong number of arguments (0 for  
> 1)

That is because what you’re really doing there is

irb\_help(OpenSSL::Random.random\_bytes())

That is, you’re calling the function OpenSSL::Random.random\_bytes, which  
requires an argument that you’re not providing. That’s where the error  
is raised.

So you need to quote the text:

irb\_help “OpenSSL::Random.random\_bytes”

However as I said already, there’s no help for this built into  
ruby/ri/rdoc.

irb(main):013:0\> irb\_help “OpenSSL::Random”  
Nothing known about OpenSSL::Random

If you’re passing a class, you don’t need to quote it, because the class  
object itself is passed and irb\_help converts it to the classname:

irb(main):014:0\> irb\_help String  
… shows info about String
