I need to make an hash I can call by hostname as the key and some random
amount of data after that as the values. now a hash works great for 1
to 1 maps (h[serverX] ==> result) but I need
h[serverX][query|result|time]
so how would I write a hash that would give me access to
If I understand correctly, you can create a class with the required
instances
variables (or use Struct or OpenStruct) and store query and result
there. For
instance, using OpenStruct:
first, thanks for the responses, ruby really is a great language.
My delima is that I’m trying to multithread the actions and store the
results in a hash with the hostname as key
to redefine the issue, for each host I need a thread and I expect a
result, then I’d like to be able to see the result in a
hash[host][result]
but I’m having trouble mixing the hash with the thread. maybe I’m going
about this all wrong. (this is outputting to a rails view, which is why
i have “@vars”
logger.info(“result of threads…”) @hostarray.each do |myhost|
logger.info("host = " + myhost + ", result = " + @resulthash[:myhost][:result])
end
logger output
host = hostX, result = --data returned from hostX–
host = hostY, result = --data returned from hostY–
result of threads…
host = hostX, result = --data returned from hostY–
host = hostY, result = --data returned from hostY–
I’m clearly loosing context of the [:host][:result] in the final two
lines.