Invoking class method within class definition

Hi,
    consider following code:

#!/usr/bin/env ruby
class Foo
  def self.bar
    puts "class method called"
  end

  def some_method
    Foo.bar # -----> self.bar will not work here
  end
end

foo = Foo.new
foo.some_method

although I can define the class method using "self", I have to use
class name to invoke the class method within the class. it would be
nice if I can invoke class method without explicitly using it's name,
so when I change my class name, I only need to change it in one place.
any way to do this?

Thanks!

def some_method
    self.class.bar
  end

will do what you want. Remember that inside #some_method, "self"
refers to the instantiated object, not the class itself.

···

On 11/3/05, T.G. <guoxiaotian@gmail.com> wrote:

class Foo
        def self.bar
                puts "class method called"
        end

        def some_method
                Foo.bar # -----> self.bar will not work here
        end
end

--
Regards,
John Wilger

-----------
Alice came to a fork in the road. "Which road do I take?" she asked.
"Where do you want to go?" responded the Cheshire cat.
"I don't know," Alice answered.
"Then," said the cat, "it doesn't matter."
- Lewis Carrol, Alice in Wonderland