Forum: Ruby on Rails RE: packages, modules

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Ross D. (Guest)
on 2006-05-25 05:45
(Received via mailing list)
> You misread this. There is no call on that line, just
> setting the variable t to the contents of the variable MD5, which is
> identical to Digest::MD5. The rest of your explanation is
> based on this
> misreading, unfortunately.

Oops being new to Ruby shows out here and Greg has pointed me in the
right direction.

> class MD5
> } You've asked the MD5 Class if it accepts the message/method
> .md5.  The
> } class does not have this method but instances of objects
> made with the
> } class do. So you could have written.
> }
> } t = Digest::MD5 # create an instance of the MD5 class
> [...]
> Nononononono. That comment is incorrect. There is no instance creation
> occurring on that line.

Again oops. The equivalent should have been'not quite so confused now')

So based on Greg's details I would think the equivalents would be:-

require 'md5'
=> true
my_md5 = MD5.md5('clearer')
=> ac27b86fdde5ffd474a51a0d7715dc56
=> "\254'\270o\335\345\377\324t\245\032\rw\025\334V"


require 'digest/md5'
=> true
my_md5 ='clearer')
=> ac27b86fdde5ffd474a51a0d7715dc56
=> "\254'\270o\335\345\377\324t\245\032\rw\025\334V"

/usr/lib/ruby/1.8/md5.rb aliases the class Digest::MD5 to MD5 and adds
the Class method MD5.md5 which is implemented as an alias to the
constructor new.

> This is both patronizing and involves a certain amount of the
> pot calling
> the kettle black. Yeesh.

Next time I'll fire up IRB and check my results before posting.  Thanks
for pointing out my errors and helping me learn.

This topic is locked and can not be replied to.