From: Henry Maddocks Date: 2013-01-08T05:29:47+09:00 Subject: Re: Newbie question: Referencing a class inside another class --Boundary_(ID_fnler67dWdZZGkxSkcCXAg) Content-type: text/plain; CHARSET=US-ASCII Content-transfer-encoding: 7BIT On 8/01/2013, at 8:08 AM, "brinda M." wrote: > I have an Error class defined inside another class in the lib directory > (i.e: Class SampleError is defined inside class > lib/third_party_api/Sample class). How do I reference SampleError from > outside class Foo class Bar def baz p "Foo Bar baz" end end end Bar.new.baz NameError: uninitialized constant Bar Use the fully qualified name Foo::Bar.new.baz "Foo Bar baz" => nil Henry --Boundary_(ID_fnler67dWdZZGkxSkcCXAg) Content-type: text/html; CHARSET=US-ASCII Content-transfer-encoding: quoted-printable lists@ruby-forum.com> = wrote:
I have an Error class defined inside another class in the = lib directory
(i.e: Class SampleError is defined inside = class
lib/third_party_api/Sample class). How do I reference = SampleError from
outside

 class Foo
   class Bar
     def baz
       p "Foo Bar = baz"
    =  end
  =  end
 end


Bar.new.baz
NameError: uninitialized constant = Bar

Use the fully qualified = name

Foo::Bar.new.baz
"Foo Bar baz"
=3D&g= t; = nil

Henry

= --Boundary_(ID_fnler67dWdZZGkxSkcCXAg)--