Hi --

On Wed, 28 Oct 2009, 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
>
> 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...
>
>
> code>
> 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

-- 
The          Ruby training with D. Black, G. Brown, J.McAnally
Compleat     Jan 22-23, 2010, Tampa, FL
Rubyist      http://www.thecompleatrubyist.com

David A. Black/Ruby Power and Light, LLC (http://www.rubypal.com)