I have three ruby classes, see below:
- base_cls.rb
File.dirname(FILE)+’/cls_factory’
class BaseCls
def self.say
ClsFactory.say
end
end
BaseCls.say
- sub_cls.rb
require File.dirname(FILE)+’/base_cls’
class SubCls < BaseCls
end
- cls_factory.rb
require File.dirname(FILE)+’/sub_cls’
class ClsFactory
def self.get_cls
SubCls.new
end
end
When I run base_cls.rb, I got this error:
base_cls.rb:5:in `say’: uninitialized constant BaseCls::ClsFactory
(NameError)
I don’t understand why this error happens? Can anyone help me on this?
thanks.