12 Jun '12, 12am

I just used a piece of code @josh_cheek wrote last year on ruby forum #AwesomeCoworkersFTW

On Aug 19, 2011, at 12:27 PM, Yu Yu wrote: > end > end > end I'm not sure what different action you plan to take if there is a double instance but: Dir.glob("test.txt") do |filename| IO.foreach(filename).inject(nil) do |last_line, line| if line =~ /#{str}/ puts "#{filename}: #{str}" if last_line == line puts "Double line" end end line end end This basically uses inject to keep a temporary holder of the last line, so you can check if it matches the previous one and take a different course of action for that case. The nil is passed as the initial value to inject so it won't match if the first string is blank. Regards, Chris White http://www.twitter.com/cwgem

Full article: http://www.ruby-forum.com/topic/2385686

Tweets

The Four Keys To Post-Penguin Directory Submission Happiness

The Four Keys To Post-Penguin Directory Submiss...

searchengineland.com 11 Jun '12, 5pm

The Google+ Local launch came out while I was working on this piece so it merits a brief mention. While Google+ Local will...

@polotek @rwaldron @timw4mail Ruby uses # to de...

railstips.org 10 Jun '12, 5pm

The other day I was explaining the difference between class and instance methods to a friend and I realized that I should ...

Passing Arguments to before_filter - Ruby Forum:

ruby-forum.com 08 Jun '12, 2am

Hi -- On 3/20/07, s.ross <[email protected]> wrote: > end > end > > Where I'm blocking is on how to get the 'options' data...

Ruby on Rails developer: Pawan Kumar Gupta from...

workingwithrails.com 09 Jun '12, 12am

Works professionally with Rails Popularity Not ranked yet. Forum Posting Rating 0% When you post on our forums other regis...

Just When You Think You Have All The Answers

Just When You Think You Have All The Answers

searchengineland.com 08 Jun '12, 6pm

I’m a big fan of the WWE (formerly WWF), and I’m not afraid to admit it – even though I probably lose all credibility when...

rbenv: A Simple, New Ruby Version Management Tool

rbenv: A Simple, New Ruby Version Management Tool

rubyinside.com 10 Jun '12, 3pm

"at least recognizing that Wayne did his damnedest to solve this problem the best he could figure how, and thus word his c...

Backspin: Johnson's win just made things spicie...

pgatour.com 11 Jun '12, 3pm

1. To play the week before a major championship, or not, that is the question. At least it was for Rory McIlroy , who brok...

Top Ruby Article: Double Shot #896:

afreshcup.com 12 Jun '12, 11am

Tuesday, June 12, 2012 at 6:22AM And this morning, I am feeling no urge whatsoever to buy a new laptop. Must be a sign of ...

Ruby 2.0 Implementation Work Begins: What is Ru...

rubyinside.com 03 Jun '12, 6pm

Yesterday, Matz made a commit to the MRI Ruby repository bumping the trunk version from 1.9.4 to 2.0.0 , marking the start...