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
i am new to ruby... and i just dont know how the scope works...
or what i am doing wrong
i took a look at the soap module
and it dosent look like it does anything
different than what i am doing...
require 'uri'
require '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
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
i am new to ruby... and i just dont know how the scope works...
or what i am doing wrong
i took a look at the soap module
and it dosent look like it does anything
different than what i am doing...
>
require 'uri'
require 'net/http'
module ModuleX
class Parser
def self.getData(d)
htmldata = self.loadData(d)
end
private
def self.loadData(profile)
That private directive isn't doing what you think. It governs instance
methods, but you're defining class methods. If you want a private
class method, you need to declare it private in the class's singleton
class:
class C
private
def self.talk
puts "hi"
end
class << self
private
def talk_privately
puts "hi privately"
end
end
end
C.talk # "hi"
C.talk_privately # error
url=''
htmldata = Net::HTTP.get(URI.parse(url))
htmldata.to_s
end
end
end
Like Gary, I can't replicate the constant error you're getting.
David
···
On Wed, 28 Oct 2009, Vic P.h. wrote:
--
The Ruby training with D. Black, G. Brown, J.McAnally
Compleat Jan 22-23, 2010, Tampa, FL
Rubyist http://www.thecompleatrubyist.com
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
Almost certainly you forgot the "require 'net/http'" in the actualy code
you're using, or else you have a typo in the 'Net' or 'HTTP'.
Ruby tries both Net::HTTP and ModuleX::Net::HTTP, and will only give
this error if both don't exist. Hence I don't believe that you have
actually loaded Net::HTTP.