From: Robert Klemme Date: 2012-01-18T04:44:57+09:00 Subject: Re: Parsing log with date time entry On Tue, Jan 17, 2012 at 8:38 PM, Christopher Graves wrote: > Thanks for pointing me in the right direction. > > I'll work on this when I get some more free time this afternoon. I'll > get back to you guys for either some more help if I get stuck or for > some code critique. You can easily cook yourself a range which uses comparisons for matching: irb(main):005:0> CompareRange = Struct.new :first, :last do irb(main):006:1* def ===(x) irb(main):007:2> x >= first && x < last irb(main):008:2> end irb(main):009:1> end => CompareRange irb(main):010:0> r=CompareRange.new Time.now-10,Time.now+2 => # irb(main):011:0> a=10.times.map {|i| r.first - 100 + i * 15} => [2012-01-17 20:40:48 +0100, 2012-01-17 20:41:03 +0100, 2012-01-17 20:41:18 +0100, 2012-01-17 20:41:33 +0100, 2012-01-17 20:41:48 +0100, 2012-01-17 20:42:03 +0100, 2012-01-17 20:42:18 +0100, 2012-01-17 20:42:33 +0100, 2012-01-17 20:42:48 +0100, 2012-01-17 20:43:03 +0100] irb(main):012:0> a.grep r => [2012-01-17 20:42:33 +0100] Note, this is simplistic but illustrates the idea. You probably also want to implement =~ operator. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/