Sijo said:
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/
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
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