Openstruct / constant negating question

Hello,
I am a newbie to Ruby. I have a nested hash converted to openstruct
(primarily for ease of access).

PreProduction
webServers
webServer1
webServer2
appServers
appServer1
appServer2 etc.,
I have the following global variables
$RCProperties -> openstruct
$RCPREPROD -> ‘PreProduction’
$RCWEBSERVER -> ‘webServers’

If I invoke it with $RCProperties.PreProduction.webServers things work
as expected. However when I try to invoke using
$RCProperties.$RCPREPROD.$RCWEBSERVERS …I am getting syntax error.
Do I need to negate the . using regular expression? If yes, I tried
using $RCProperties.$RCPreprod.$RCWEBSERVERS but still getting the
same error message.
Any help would be highly appreciated.

Thanks
Pugal

On 16.04.2007 17:28, Pugal Panneerselvam wrote:

I am a newbie to Ruby. I have a nested hash converted to openstruct
(primarily for ease of access).

It seems you made your access more complicated…

$RCWEBSERVER -> ‘webServers’

If I invoke it with $RCProperties.PreProduction.webServers things work
as expected. However when I try to invoke using
$RCProperties.$RCPREPROD.$RCWEBSERVERS …I am getting syntax error.
Do I need to negate the . using regular expression? If yes, I tried
using $RCProperties.$RCPreprod.$RCWEBSERVERS but still getting the
same error message.

You need to either do

$RCProperties.PreProduction.webServers

or

$RCProperties.send($RCPREPROD).send($RCWEBSERVER)

or revert back to Hashes and do

$RCProperties[$RCPREPROD][$RCWEBSERVER]

Kind regards

robert

It works. Thank you.