From: Rob Biedenharn Date: 2009-09-16T07:23:00+09:00 Subject: Re: range On Sep 15, 2009, at 6:11 PM, Sebastian Hungerecker wrote: > Am Mittwoch 16 September 2009 00:06:21 schrieb Re BR: >> how can I convert a string '20-30' to a instance range object 20..30 > > first, last = '20-30'.split("-") > first.to_i .. last.to_i > #=> 20..30 > > HTH, > Sebastian Or: string="20-30" Range.new(*(string.split('-',2).map{|s|s.to_i})) in English, split the string into at most two parts at the '-', map those parts as integers, and use them to build a new Range. -Rob Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com