Iñaki Baz Castillo:
module MyProgram
class Logger
class << self
def debug …
…
end
end
end
end
Ok, this seems really ellegant and I've tested that I can call
"Logger.debug..." in any submodule/subclass into the program 

Just a question: Logger must use an instance of a class (real
class Logger), so to store it I think the best option is using
a @@class_variable into Logger module
No – by using class << self, you’re operating on the Logger object
(an instance of the class Class), and you can access its *instance*
variables. That’s the other elegant part about this solution – you can
use anything you’re used to, including, for example, attr_accessors.
I use this approach like in the below code; I can use stuff like
$stderr.puts 'some debug line' if Config.debug
1.upto Config.max_pins do |pin|
…
end
or decide whether to use Enumerable#map or the forkoff
gem based on whether Config.processes is one or more. 
shot@asterix:~/work/PhD/bzr/trunk$ cat lib/art-decomp/config.rb
module ArtDecomp class Config
class << self
attr_accessor :debug, :processes, :qu_method, :qv_method, :silicone
def init
@debug = false
@processes = 1
@qu_method = :graph_merger
@qv_method = :graph_merger
@silicone = Set[Arch[4,2], Arch[5,1]]
end
def log string, run, runs, dawn
left = ((Time.now - dawn)/run*(runs - run)).ceil
$stderr << " [#{string} #{runs - run} #{left}s] " if Config.debug
end
def max_pins
@silicone.map{|arch| arch.pins}.max
end
def max_pons
@silicone.map{|arch| arch.pons}.max
end
alias reset init
end
end end
ArtDecomp::Config.init
shot@asterix:~/work/PhD/bzr/trunk$
-- Shot
···
El Jueves, 26 de Junio de 2008, Shot (Piotr Szotkowski) escribió:
--
Smalltalk itself generates its own refactoring browser, test rig, IDE,
and 3D graphics subsystems as you write your program with it. So as you
structure your program, Smalltalk uses that structure to generate the
refactoring browser needed to refactor its structure. This is why some
advanced Smalltalk Gurus know the best way to program Smalltalk is to
simply pick up the CPU and shake it. -- Phlip, comp.programming