Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > how to read this

Reply
Thread Tools

how to read this

 
 
msoulier
Guest
Posts: n/a
 
      11-06-2009
I was recently looking to compute a sha1 hash in ruby, and l luckily
google turned up a quick example because I found the digest docs here
http://www.ruby-doc.org/stdlib/ very cryptic and difficult to read.

How am I to interpret what I see in the digest api docs? There's no
example, not even an obvious entry point. How do I look at that doc
and know what I need to "require" and then what classes I'll be using
to accomplish my task?

Luckily this dude and google to the rescue http://snippets.dzone.com/posts/show/83.

Mike
 
Reply With Quote
 
 
 
 
Sven Schott
Guest
Posts: n/a
 
      11-06-2009
[Note: parts of this message were removed to make it a legal post.]

I have usually found that either the base class or file usually have the
details for usage. I admit the digest class docs are a bit sparse but they
are there.

http://www.ruby-doc.org/stdlib/libdo...est/Class.html

It shows an example for both a string and a file. As for the require, I
usually just require the file or folder at the base of the list of files. In
this case it is 'digest'.

On Sat, Nov 7, 2009 at 2:00 AM, msoulier <> wrote:

> I was recently looking to compute a sha1 hash in ruby, and l luckily
> google turned up a quick example because I found the digest docs here
> http://www.ruby-doc.org/stdlib/ very cryptic and difficult to read.
>
> How am I to interpret what I see in the digest api docs? There's no
> example, not even an obvious entry point. How do I look at that doc
> and know what I need to "require" and then what classes I'll be using
> to accomplish my task?
>
> Luckily this dude and google to the rescue
> http://snippets.dzone.com/posts/show/83.
>
> Mike
>
>


 
Reply With Quote
 
 
 
 
Brian Candler
Guest
Posts: n/a
 
      11-09-2009
Sven Schott wrote:
> http://www.ruby-doc.org/stdlib/libdo...est/Class.html
>
> It shows an example for both a string and a file.


You can also build up a digest iteratively:

require 'digest/sha1'
d = Digest::SHA1.new
d << "hello"
d << " world"
puts d.hexdigest # or d.digest for binary
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
msoulier
Guest
Posts: n/a
 
      11-12-2009
On Nov 6, 4:12*pm, Sven Schott <sven.sch...@gmail.com> wrote:
> I have usually found that either the base class or file usually have the
> details for usage. I admit the digest class docs are a bit sparse but they
> are there.


Yeah, sort of. No hard example for SHA1, but you can replace Class
with SHA1 and you're good I suppose.

I tried modifying the digest.rb file in my source tarball and re-
running "rdoc --ri" over the whole tree, and it did not capture my
rdoc at all. If I run "ri Digest" it finds nothing.

If I instead cd into the directory containing the digest.rb file and
run "rdoc --ri" then it gets picked up. I was hoping to submit a patch
with better docs, but I'm curious as to why my rdoc wasn't picked up
if I run it at the top level of the source tree. Any ideas?

make install-doc basically runs "rdoc --ri", and it didn't pick up my
changes either.

Mike
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Help: Program to read from EOR end of last read? snoopy_@excite.com Java 3 04-07-2006 12:32 PM
Binary data stored in SQL Server: can't read from ASP.NET, *can* read from Access? Doug ASP .Net 3 11-04-2005 07:35 PM
Re: Unable to read video DVDs and can read Data DVDs Biz DVD Video 0 07-22-2005 03:44 AM
Re: How to change Read Only Constraint to Read-Write Isaac VHDL 0 07-10-2003 01:43 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57