On 28 May 2010 15:10, Rob Biedenharn <Rob@agileconsultingllc.com> wrote:
> irb> row_count = (array.length + (3-1))/3
That looks a little clunky to me... I'd rather use
(array.length / 3.0).ceil
No difference in the result though! :-)
But the OP's request is a little vague as people have pointed out -
Should the three groups be 'shuffled' (ie one of each of the first
three elements in each column, and one of each of the next three, and
so on...)? or is it the 1st, 2nd, and 3rd third of elements grouped
together? is it three arrays of equal size for use in the controller?
or three columns in a view that's needed? and if in the view, is it
data that can be presented in an HTML table, or will it be CSS floated
layout elements?
Hopefully though, there's been enough suggestions and pointers to the
API docs for Enumerable for the OP to get a result :-)
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment