Answer: Many friends have already said that.
class DataImport
def self.say_hi
puts "hi"
end
end
And the reason is that if you have a class and a method without yourself. You cannot call the ClassName.method class. You can call it like this if only the method is the self method of this class.
Otherwise, you can call as ClassName.new.method.
In your problem you can call as
DataImport.new.say_hi
And the class remains the same as you.
source
share