On 2/2/2011 1:53 AM, Kamarulnizam Rahim wrote:
> Thanks Jeremy,
> 
> I am able to solve the problem regarding indentation by changing the 
> code as posted. There is one little question i want to ask.
> 
> How do convert these two hashes:
> 
> [{xxxxxx},{yyyyyy}]
> 
> to be like this:
> 
> [{xxxxxx, yyyyyy}]
> 
> Is it possible at all?

Check out Hash#merge.  Assuming you have an array of hashes in the
variable arr, you could merge them all like this:

arr.inject({}, &:merge)

Give that a try in irb and see if you can fit it into your code.

> Regarding the Environmental class. I still need that class because i 
> want to open my yaml file to be used by many subclasses, not just 
> EnergyManagement only. Thanks

I'm not saying that you don't need the Environmental class at all.  You
just don't need to make the EnergyManagement class inherit from it in
order to use it the way you are in the code.  Calling Environmental.yaml
will still work.

-Jeremy