Hi everyone,
I’m looking for the fastest way (or the version with the least code!) to
consolidate a couple of arrays.
Basically, what a dump of what I have is this:
[[#<Ifinoctets_26 id: 2476, dtime: “2009-04-28 00:00:34”, counter:
675392602>, #<Ifinoctets_26 id: 2476, dtime: “2009-04-28 00:05:34”,
counter: 652224867>, #<Ifinoctets_26 id: 2476, dtime: “2009-04-28
00:10:34”, counter: 637505981>, #<Ifinoctets_26 id: 2476, dtime:
“2009-04-28 00:15:34”, counter: 813981324>, #<Ifinoctets_26 id: 2476,
dtime: “2009-04-28 00:20:34”, counter: 753826918>],
[#<Ifinoctets_26 id: 2477, dtime: “2009-04-28 00:00:37”, counter:
287888720>, #<Ifinoctets_26 id: 2477, dtime: “2009-04-28 00:05:37”,
counter: 260326966>, #<Ifinoctets_26 id: 2477, dtime: “2009-04-28
00:10:37”, counter: 287575144>, #<Ifinoctets_26 id: 2477, dtime:
“2009-04-28 00:15:37”, counter: 341606600>, #<Ifinoctets_26 id: 2477,
dtime: “2009-04-28 00:20:37”, counter: 305102837>],
[#<Ifinoctets_28 id: 2484, dtime: “2009-04-28 00:00:36”, counter:
2976043831>, #<Ifinoctets_28 id: 2484, dtime: “2009-04-28 00:05:36”,
counter: 2904676029>, #<Ifinoctets_28 id: 2484, dtime: “2009-04-28
00:10:36”, counter: 2901969681>, #<Ifinoctets_28 id: 2484, dtime:
“2009-04-28 00:15:36”, counter: 2827196523>, #<Ifinoctets_28 id: 2484,
dtime: “2009-04-28 00:20:36”, counter: 2532538201>]]
I need to be able to grab the first record of each array (that happens
to be within the outer array) and merge them into one, keeping the
class, ID, and dtime of the first of the three and the SUMMED counter of
all three. In reality there could be anywhere between 2 and 30 arrays in
there each with any number of records. So let’s say we have:
#<Ifinoctets_1 id: 100, dtime: “2009-04-28 00:00:34”, counter: 500>
+
#<Ifinoctets_2 id: 111, dtime: “2009-04-28 00:00:37”, counter: 1000>
+
#<Ifinoctets_3 id: 122, dtime: “2009-04-28 00:00:36”, counter: 500>
=
#<Ifinoctets_1 id: 100, dtime: “2009-04-28 00:00:34”, counter: 2000>