Hi --
On Sat, 20 Jun 2009, Max Williams wrote:
> I'm in an irb session where i have a lot of modules loaded. All of the
> modules have a common parent, 'Thoth'. So, i'm referring to lots of
> classes called 'Thoth:
ost', 'Thoth::Tag', 'Thoth:
age' etc.
>
> To save some typing, i'd just like to refer to these classes as Post,
> Tag or Page. Is there a way i can sort of 'move into' the Thoth module,
> so i don't have to keep namespacing the classes all the time?
>
> Sorry if i'm not explaining this very well, i'm possibly showing off my
> ignorance about the relationship between classes and modules here...
You can use the irb command inside irb:
irb(main):001:0> module M; X=1; end
=> 1
irb(main):002:0> irb M
irb#1(M):001:0> X
=> 1
This puts you in a context where the object you've irb'd is self. (Use
'exit' to get back to your top-level irb session.) You could also
include the module, or reopen it. There are some differences among
these techniques, but somewhere in there you can probably find
something.
David
--
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training:
http://www.rubypal.com
Now available: The Well-Grounded Rubyist (
http://manning.com/black2)
"Ruby 1.9: What You Need To Know" Envycasts with David A. Black
http://www.envycasts.com