Reputation: 19061
Say I have,
class Foo
def self.bar
puts "I want to print #{some_method_for_class_name} and #{some_method_for_method_name}."
end
end
Is there some way to get "Foo" and "bar" in the place for some_method_for_class_name
and some_method_for_method_name
respectively?
Upvotes: 1
Views: 90
Reputation: 1347
Something like this should work:
class Foo
def self.bar
puts "I want to print #{self} and #{__method__}."
end
end
If it was not a class method you'd need to use self.class
instead.
Upvotes: 2