On Nov 11, 2008, at 5:45 PM, Todd Benson wrote:

> On Tue, Nov 11, 2008 at 4:29 PM, Stuart Clarke
> <stuart.clarke1986 / gmail.com> wrote:
>> Hi all,
>>
>> I have a quick brain teaser. I  have an array full of data broken  
>> down
>> into indivdual entries. I running a simple if statement to check  
>> for an
>> entry in the array, if my if statement finds that entry its prints  
>> out
>> that entry. I want to add an extra step into this so, when my if
>> statement finds an entry, I want it to look at the next entry and  
>> check
>> for something else, if it finds that, I want to look at the next  
>> entry
>> and check for something else, if it finds all of the three entries  
>> in a
>> row, it prints out "You have found what you want"
>>
>> Any ideas?
>
> Depends on the objects in the array, but you might try #join followed
> by #include?.
>
> Todd


See Enumerable#each_cons

your_array.each_cons(3) do |entry, something, something_else|
   puts "You have found what you want" if complex_condition
end

-Rob

Rob Biedenharn		http://agileconsultingllc.com
Rob / AgileConsultingLLC.com