Out of the following the last one does not work:
puts node.elasticsearch[:plugin][:jetty][:name]
puts node.elasticsearch[:plugin]['jetty'][:name]
puts node.elasticsearch[:plugin]["'#{entry}'"][:name]
What syntax do I need to follow in order to use a variable’s value in the index when accessing a multi dimensional array?
UPDATE:
I think entry is a String but I could be wrong so here’s the statement that sets it up for you the educated helper to determine what’s what:
Dir.entries("/var/plugins/").any? do |entry|
puts node.elasticsearch[:plugin][:jetty][:name]
puts node.elasticsearch[:plugin]['jetty'][:name]
puts node.elasticsearch[:plugin]["'#{entry}'"][:name]
end
Your hash is indexed with symbols, so you should convert your string into a symbol, with
entry.intern().Edit:
to_symandinternare aliases of the String class. So entry has to be a string, which it seems to be according to your attempts.