From: "Simon Kröger" Date: 2006-03-25T21:11:27+09:00 Subject: Re: require a certain version of the ruby interpreter >> [...] >> :) Even I couldn't find an excuse for inject on this one. The best I >> could do was: >> >> def ensure_version(v) >> raise "need #{v}" if VERSION.split('.').zip(v.split('.')).any? >> {|a,b| a < b} >> end > > Nice, too! I like the approach with any?. Yeah, me too. But its a bit buggy: v = '1.8.5' p '1.8.4'.split('.').zip(v.split('.')).any? {|a,b| a < b} #=> true v = '0.0.9' p '1.8.4'.split('.').zip(v.split('.')).any? {|a,b| a < b} #=> true >> (given that we don't need to worry about two-digit versions of course). we could just use string compare, right? (no inject, no any?, no fun of course :)) what about VERSION.gsub(/(\d+)/){$1.to_i.chr} >= v.gsub(/(\d+)/){$1.to_i.chr} this works up to version 255.255.255 *g* cheers Simon