考慮我有散列的數組(這是我的地圖從MongoDB的輸出/減少),這類似於以下內容:紅寶石轉化散,組合多個值
[
{"minute"=>30.0, "hour"=>15.0, "date"=>5.0, "month"=>9.0, "year"=>2011.0, "type"=>10.0, "count"=>299.0},
{"minute"=>0.0, "hour"=>16.0, "date"=>5.0, "month"=>9.0, "year"=>2011.0, "type"=>10.0, "count"=>477.0},
...
]
但我不希望所有那些與時間相關的鍵和值,我想將它們合併到每個對象的日期對象中,將符號用作我的鍵而不是字符串會更有效嗎?
[
{timestamp: DateTime.new(2011.0, 9.0, 5.0, 15.0, 30.0), count: 299, type: 10},
{timestamp: DateTime.new(2011.0, 9.0, 5.0, 16.0, 0.0), count: 477, type: 10},
...
]
任何幫助,這將是非常棒的。謝謝!
它只是一個地圖,我沒有看到這個問題...至少展示你試過的東西。 – tokland