# How to read this

**URL:** <https://www.ruby-forum.com/t/how-to-read-this/178567>\
**Category:** Ruby\
**Created:** [November 6, 2009, 4:00pm UTC](https://www.ruby-forum.com/t/how-to-read-this/178567 "2009-11-06T16:00:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![msoulier](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@msoulier](https://www.ruby-forum.com/u/msoulier)\
**Post date:** [November 6, 2009, 4:00pm UTC](https://www.ruby-forum.com/t/how-to-read-this/178567/1 "2009-11-06T16:00:30Z")

</div>

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  
[RDoc Documentation](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](http://snippets.dzone.com/posts/show/83).

Mike

---

<div class="post-metadata">

**Author:** ![msoulier](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@msoulier](https://www.ruby-forum.com/u/msoulier)\
**Post date:** [November 6, 2009, 10:13pm UTC](https://www.ruby-forum.com/t/how-to-read-this/178567/2 "2009-11-06T22:13:25Z")

</div>

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/libdoc/digest/rdoc/classes/Digest/Class.html](http://www.ruby-doc.org/stdlib/libdoc/digest/rdoc/classes/Digest/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’.

---

<div class="post-metadata">

**Author:** ![msoulier](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@msoulier](https://www.ruby-forum.com/u/msoulier)\
**Post date:** [November 9, 2009, 3:06pm UTC](https://www.ruby-forum.com/t/how-to-read-this/178567/3 "2009-11-09T15:06:33Z")

</div>

Sven S. wrote:

> [http://www.ruby-doc.org/stdlib/libdoc/digest/rdoc/classes/Digest/Class.html](http://www.ruby-doc.org/stdlib/libdoc/digest/rdoc/classes/Digest/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

---

<div class="post-metadata">

**Author:** ![msoulier](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@msoulier](https://www.ruby-forum.com/u/msoulier)\
**Post date:** [November 12, 2009, 7:37pm UTC](https://www.ruby-forum.com/t/how-to-read-this/178567/4 "2009-11-12T19:37:26Z")

</div>

On Nov 6, 4:12 pm, Sven S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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
