From: ara.t.howard@... Date: 2006-08-03T07:10:34+09:00 Subject: Re: Can't convert String into Integer (TypeError) On Thu, 3 Aug 2006, Timothy Hunter wrote: > ara.t.howard@noaa.gov wrote: >> jib:~ > ruby -r RMagick -e' p >> Magick::Image.instance_methods.grep(/raise/) ' >> ["raise"] >> >> >> btw, seems like you could get away with something like: >> >> pct = Float(pct) rescue (Float(pct.to_s.delete('%'))/100) >> r = 0.0 .. 1.0 >> pct = [r.min, pct].max >> pct = [r.max, pct].min >> >> cheers. >> >> -a > Arg! I should spend more time coding in Ruby and less in C. Thanks, Ara! yeah - i have the opposite issue ;-) > "1%0%".delete('%') => "10". Might be a bit too tolerent, don't you think? dunno. you could do pct.sub(/%$/,'') too. lately i've found that parameter checking just comes back to haunt me - though i do it heavily in certain situations. just food for thought. > I had the clamping down to 1 line but when I looked at it the next day I > couldn't tell if it was correct or not :-( indeed - i tend even to avoid method chaining in production code for that reason - it makes logs less than useful for pinpointng errors cheers. -a -- we can never obtain peace in the outer world until we make peace with ourselves. - h.h. the 14th dali lama