Robert Klemme
2/6/2009 2:59:00 PM
2009/2/5 David Stanford <dthomas53@hotmail.com>:
> Judging from everyone's response, it sounds like what I'm trying to do
> isn't typically done.
Agreed.
> My mindset was, first, to simply create a standard
> class. While creating one of the object methods for that class, I
> realized that the same method code would be useful to call directly,
> without having to create an object instance; so, as I said, I was
> thinking there must be some way to do this, without repeating the same
> (or a similar piece) of code somewhere else.
In that case I would have the method definition *only* at class level
since apparently it is independent of instance state. I wouldn't even
have it as instance method at all. That avoids confusion. If you
need to invoke the method from instance methods the
self.class.a_method() idiom works well IMHO.
Kind regards
robert
--
remember.guy do |as, often| as.you_can - without end