Another DSL question

M

Matt Lawrence

I have another DSL question. I have a bunch of data in a tree (a
directory tree) that I need to access. Ideally, I would like to be able
to reference items as a.b.c, but I'm not able to figure out the syntax for
declaring it.

This is a bunch of information about a bunch of systems, I would like to
be able to do something like:

sys1 = Profile.new("dbserver03")
puts sys1.hypervisor.maxmem

Right now I can do
sys1=Profile.new("dbserver03")
puts sys1.hypervisor["maxmem"]

but it is a bit ugly. How can I declare things so I can just do a.b.c?

-- Matt
It's not what I know that counts.
It's what I can remember in time to use.
 
B

botp

sys1=3DProfile.new("dbserver03")
puts sys1.hypervisor["maxmem"]
but it is a bit ugly. =A0How can I declare things so I can just do a.b.c?

check #method_missing

best regards -botp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,044
Latest member
RonaldNen

Latest Threads

Top