inet_stream do |s|
Is this actually a class and where is its “end”?
It is a class; it’s the singleton class of log. You may join the club
of people who want a singleton_class method That would make it:
As it stands, in order to address the singleton class as an object,
you have to capture it through the technique of:
class << log
self
end
What you’re seeing in the code you’ve got is this, but strung together
on one line without much to help you parse it visually if you don’t
already know what to expect. I would tend to write it as:
…
What you’re seeing in the code you’ve got is this, but strung together
on one line without much to help you parse it visually if you don’t
already know what to expect. I would tend to write it as:
(class << log; self; end).send etc.
David
Thanks David. And there I was thinking us C++ folks were good at writing
incomprehsible code.
but maybe you should also read the previous chapters as well, it
shouldn’t
take more than some hours to have the big picture clear in your mind.
the documentation is based upon ruby 1.7.3, IIRC, and I don’t know
what’s
changed later, but I’m sure that the overall cleanness of MRI hasn’t
been
altered :).
def post_scriptum; puts yield end
post_scriptum do %{
hello list! this is my first post!
lurking from some months, I learned a lot from you all!
thanks!
} end
What you’re seeing in the code you’ve got is this, but strung together
on one line without much to help you parse it visually if you don’t
already know what to expect. I would tend to write it as:
(class << log; self; end).send etc.
I’d add that
send(:define_method, :to_int)
is used instead of simply:
define_method(:to_int)
to override the private status of ‘define_method’.
Gary W.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.