Forum: Ruby shell.rb and class << Shell

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D812408537ac3a0fa2fec96eb8811559?d=identicon&s=25 John Carter (Guest)
on 2006-04-13 03:24
(Received via mailing list)
I'm confuzzled.

In lib/shell.rb I read...

============================================================
class Shell
   @RCS_ID='-$Id: shell.rb,v 1.8 2001/03/19 09:01:11 keiju Exp keiju $-'

   include Error
   extend Exception2MessageMapper

#  @cascade = true
   # debug: true -> normal debug
   # debug: 1    -> eval definition debug
   # debug: 2    -> detail inspect debug
   @debug = false
   @verbose = true

   class << Shell
=============================================================

Question 1.
   Why does he use this "class << Shell" trick? What does that do?

Question 2.
   What does Exception2MessageMapper do? Yes, I have read the comments
   three times, and I still don't know what it does or why.



John Carter                             Phone : (64)(3) 358 6639
Tait Electronics                        Fax   : (64)(3) 359 4632
PO Box 1645 Christchurch                Email : john.carter@tait.co.nz
New Zealand

Carter's Clarification of Murphy's Law.

"Things only ever go right so that they may go more spectacularly wrong
later."

From this principle, all of life and physics may be deduced.
31ab75f7ddda241830659630746cdd3a?d=identicon&s=25 Austin Ziegler (Guest)
on 2006-04-13 04:10
(Received via mailing list)
On 4/12/06, John Carter <john.carter@tait.co.nz> wrote:
> Question 1.
>    Why does he use this "class << Shell" trick? What does that do?

This is equivalent to:

  class Shell
    class << self
    end
  end

The latter you should be familiar with from numerous postings on the
list.

> Question 2.
>    What does Exception2MessageMapper do? Yes, I have read the comments
>    three times, and I still don't know what it does or why.

You'll need to look at lib/e2mm.rb for details, but it seems to create
a framework for exceptions with default error messages.

-austin
This topic is locked and can not be replied to.