Xavier Noria
12/6/2007 10:52:00 PM
On Dec 6, 2007, at 11:33 PM, Raimon Fs wrote:
> I'm using your first suggestion:
>
>> values = invoice_calculs.map do |ic|
>> ic.attributes
>> end.map do |a|
>> a.values
>> end.flatten
>
> with or without the .flatten all the values are written at the same
> time
> ...
>
> your new suggestion : invoice_calculs.map(&:attributes).map(&:values)
>
> also writtes the three values at one time, I need each value
> separated:
>
> element one:
> 82567.3695778.2113210.85
>
> and I need:
> 82567.36
> 95778.21
> 13210.85
>
> I hope it's more clear what I'm trying to do now ...
The version with flatten gives you all the values in a row in a single
array. From the YAML dump that would be
["82567.36", 95778.21", "13210.85", "17.91", "255.81", "273.72", ...]
The version without flatten gives an array of arrays. Each array
element contains the values corresponding to a single InvoicesCalcul:
[["82567.36", 95778.21", "13210.85"], ["17.91", "255.81",
"273.72"], ...]
Please use that array notation to indicate how would the desired
result look like if it is none of those.
-- fxn