クラス内でselfメソッドをクラス名を指定せず呼び出したい
解決
self.class.method_name で呼び出す
class Person
def call(num)
puts "#{self.class.name(num)}だよ"
end
def self.name(num)
if num = 1
'田中'
else
'名無し'
end
end
end
This post is licensed under CC BY 4.0 by the author.