From: Marcin Grzywaczewski Date: 2007-09-03T05:30:02+09:00 Subject: Re: extract a range start/end? ------=_Part_12115_23263583.1188764999219 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 2007/9/2, Michael Linfield : > > if i have a list of dates in an array such as: > > 4/2/07 > 4/3/07 > 4/4/07 > 4/5/07 > 4/6/07 > 4/7/07 > 4/8/07 > ect. > > how would i..based on option parse..pull a starting point and end point > of to extract that data range. > > IE: > > opts = OptionParser.new do |opts| > opts.on("-s", "--startdate", "What start date to use." do |i| > #code to determine to use the starting date > end > > # the same would apply to an --enddate > > any ideas? > > i was thinking i could possibly create a new range depending on what the > user input was by doing > > require 'date' > results = [] > > (Date.new(2007,4,1)..Date.new(2007,4,8)).each {|r| res << r} > but then how would i match that against the original dates for the data? > > feel free to give me any thoughts. > > -Thanks > -- > Posted via http://www.ruby-forum.com/. I think that range operates on numbers, and method "to_i" casts class to number, so your class should have specific method "to_i". Yours, Killavus. ------=_Part_12115_23263583.1188764999219--