Vic P.h. wrote:> i got a module x and then a class z and inside this class i do a
> Net::HTTP call and it looks for it inside module x ... and i am
> clueless...
>
> i get uninitialized constant ModuleX::Net::HTTP
>
[...]> module ModuleX
>
> class Parser
> def self.getData(d)
> htmldata = self.loadData(d)
> end
> private
> def self.loadData(profile)
> url=''''
> htmldata = Net::HTTP.get(URI.parse(url))
> htmldata.to_s
> end
> end
>
> end
Right. Since you''re in ModuleX, everything is assumed to be in the
scope of ModuleX unless fully qualified. So Parser is ModuleX::Parser
(which is what you want), and Net::HTTP is ModuleX::Net::HTTP (which you
don''t want). To force global scope on Net::HTTP, just qualify it by
prefixing the scope operator, so you''d write it as
::Net::HTTP.>
> in advance thanks for shading light
You''re welcome!
Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org
--
Posted via http://www.ruby-forum.com/.