Another DSL question

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.

On Fri, Oct 29, 2010 at 11:14 PM, Matt L. [email protected]
wrote:

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?

check #method_missing

best regards -botp

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs