On 16 June 2010 16:57, Michael Pavling <pavl...@gmail.com> wrote: > On 16 June 2010 15:51, Ants Pants <antsmailingl...@gmail.com> wrote: > > I don't have a problem with comparing floats, but I might need to find > the > > 10 closest times to the actual event time and 4 of those times could be > less > > than the actual event time and 6 could be higher. > > As a starting point, IIWM I would: > * Get the ten times either side (so I have twenty objects). > * Calculate the difference of how far each is from the event (ignoring > sign) > * Order the twenty by the difference > * Take the first ten of them. > > With a bit of thought this could all be done in SQL... possibly with a > couple of sub-queries. But it could certainly be stepped through in > Ruby very easily. > > -- > 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-t...@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com<rubyonrails-talk%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > As I have said before, I have no problems with all of that but thanks for the suggestions. Things do get a bit more complicated with the Calculator, though and I was only looking to make sure I wasn't wasting my time when there was something already out there.
I'll just press on. Again, thanks for your time. -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.