# Raise unless RUBY\_VERSION\[%r/^\\s\*\\d+\\.\\d+/o\].to\_f \>= 1.8

**URL:** <https://rubytalk.org/t/raise-unless-ruby-version-r-s-d-d-o-to-f-1-8/9032>\
**Category:** ruby-talk\
**Created:** [24 November 2003 23:32 UTC](https://rubytalk.org/t/raise-unless-ruby-version-r-s-d-d-o-to-f-1-8/9032 "2003-11-24T23:32:14Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ara.T.Howard2](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@Ara.T.Howard2](https://rubytalk.org/u/Ara.T.Howard2)\
**Post date:** [24 November 2003 23:32 UTC](https://rubytalk.org/t/raise-unless-ruby-version-r-s-d-d-o-to-f-1-8/9032/1 "2003-11-24T23:32:14Z")

</div>

any better methods of require a specific version/set of versions?

-a

> **···**
>
> –
> 
> ATTN: please update your address books with address below!
> 
> ===============================================================================
> 
> > EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov  
> > PHONE :: 303.497.6469  
> > ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328  
> > STP :: [Solar-Terrestrial Physics Data | NCEI](http://www.ngdc.noaa.gov/stp/)  
> > NGDC :: [http://www.ngdc.noaa.gov/](http://www.ngdc.noaa.gov/)  
> > NESDIS :: [http://www.nesdis.noaa.gov/](http://www.nesdis.noaa.gov/)  
> > NOAA :: [http://www.noaa.gov/](http://www.noaa.gov/)  
> > US DOC :: [http://www.commerce.gov/](http://www.commerce.gov/)
> > 
> > The difference between art and science is that science is what we  
> > understand well enough to explain to a computer.  
> > Art is everything else.  
> > – Donald Knuth, “Discover”
> > 
> > /bin/sh -c ‘for l in ruby perl;do $l -e “print "\x3a\x2d\x29\x0a"”;done’  
> > ===============================================================================

---

<div class="post-metadata">

**Author:** ![Michael\_Campbell1](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@Michael\_Campbell1](https://rubytalk.org/u/Michael_Campbell1)\
**Post date:** [24 November 2003 23:41 UTC](https://rubytalk.org/t/raise-unless-ruby-version-r-s-d-d-o-to-f-1-8/9032/2 "2003-11-24T23:41:34Z")

</div>

Ara.T.Howard wrote:

> any better methods of require a specific version/set of versions?
> 
> -a

This might be a good thing to encapsulate somehow; perl has a construct  
like so:

require 5;

which requires that the version of perl running the script be \>= 5.  
(IIRC, you can “require” arbitrary levels, like ``require 5.0.1;‘’, but  
I might be mistaken on that.)

Given ruby is changing in fairly large chunks, this might be useful.

---

<div class="post-metadata">

**Author:** ![Florian\_Gross](https://avatars.discourse-cdn.com/v4/letter/f/e9a140/32.png) [@Florian\_Gross](https://rubytalk.org/u/Florian_Gross)\
**Post date:** [24 November 2003 23:54 UTC](https://rubytalk.org/t/raise-unless-ruby-version-r-s-d-d-o-to-f-1-8/9032/3 "2003-11-24T23:54:02Z")

</div>

Moin!

Ara.T.Howard wrote:

> any better methods of require a specific version/set of versions?

What about RUBY\_VERSION \>= “1.8.0”?

Regards,  
Florian Gross

---

<div class="post-metadata">

**Author:** ![Chad\_Fowler](https://avatars.discourse-cdn.com/v4/letter/c/5daacb/32.png) [@Chad\_Fowler](https://rubytalk.org/u/Chad_Fowler)\
**Post date:** [25 November 2003 01:09 UTC](https://rubytalk.org/t/raise-unless-ruby-version-r-s-d-d-o-to-f-1-8/9032/4 "2003-11-25T01:09:59Z")

</div>



---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://rubytalk.org/u/Robert)\
**Post date:** [25 November 2003 08:42 UTC](https://rubytalk.org/t/raise-unless-ruby-version-r-s-d-d-o-to-f-1-8/9032/5 "2003-11-25T08:42:12Z")

</div>

“Ara.T.Howard” [ahoward@ngdc.noaa.gov](mailto:ahoward@ngdc.noaa.gov) schrieb im Newsbeitrag  
[news:Pine.LNX.4.44.0311241336440.28055-100000@fattire.ngdc.noaa.gov](mailto:news:Pine.LNX.4.44.0311241336440.28055-100000@fattire.ngdc.noaa.gov)…

> any better methods of require a specific version/set of versions?

A bit more complicated, but could be included in the std. distribution…

module Kernel  
def ensure\_version( ver )  
if ( RUBY\_VERSION.split(/./).map{|x|x.to\_i} \<=\>  
ver.split(/./).map{|x|x.to\_i} ) \< 0  
throw “Version error: should be #{ver} but is #{RUBY\_VERSION}”  
end  
end  
end

ensure\_version “1.7.0”  
ensure\_version “1.8.0”  
ensure\_version “1.8.1”

Cheers

```
robert

```

---

<div class="post-metadata">

**Author:** ![Paul\_Brannan](https://avatars.discourse-cdn.com/v4/letter/p/76d3ee/32.png) [@Paul\_Brannan](https://rubytalk.org/u/Paul_Brannan)\
**Post date:** [26 November 2003 21:40 UTC](https://rubytalk.org/t/raise-unless-ruby-version-r-s-d-d-o-to-f-1-8/9032/6 "2003-11-26T21:40:52Z")

</div>

require ‘rbconfig’

major = Config::CONFIG[‘MAJOR’].to\_i  
minor = Config::CONFIG[‘MINOR’].to\_i  
teeny = Config::CONFIG[‘TEENY’].to\_i  
if major \< 1 or (major == 1 and minor \< 8) then  
raise “wrong version”  
end

Of course, this can be wrapped into a nice version class. I wrote one  
of these a long time ago and never released it, but there are plenty of  
others already out there.

Paul

> **···**
>
> On Tue, Nov 25, 2003 at 08:32:14AM +0900, Ara.T.Howard wrote:
> 
> > any better methods of require a specific version/set of versions?

---

<div class="post-metadata">

**Author:** ![Joel\_VanderWerf1](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@Joel\_VanderWerf1](https://rubytalk.org/u/Joel_VanderWerf1)\
**Post date:** [25 November 2003 02:10 UTC](https://rubytalk.org/t/raise-unless-ruby-version-r-s-d-d-o-to-f-1-8/9032/7 "2003-11-25T02:10:57Z")

</div>

Florian Gross wrote:

> Moin!
> 
> Ara.T.Howard wrote:
> 
> > any better methods of require a specific version/set of versions?
> 
> What about RUBY\_VERSION \>= “1.8.0”?

Or:

irb(main):001:0\> RUBY\_VERSION  
=\> “1.8.1”  
irb(main):002:0\> RUBY\_VERSION.to\_f  
=\> 1.8  
irb(main):003:0\> RUBY\_VERSION.to\_f \>= 1.8  
=\> true

---

<div class="post-metadata">

**Author:** ![Ara.T.Howard2](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@Ara.T.Howard2](https://rubytalk.org/u/Ara.T.Howard2)\
**Post date:** [25 November 2003 04:32 UTC](https://rubytalk.org/t/raise-unless-ruby-version-r-s-d-d-o-to-f-1-8/9032/8 "2003-11-25T04:32:12Z")

</div>

completely agreed.

-a

> **···**
>
> On Tue, 25 Nov 2003, Michael campbell wrote:
> 
> > Date: Tue, 25 Nov 2003 08:41:34 +0900  
> > From: Michael campbell [michael\_s\_campbell@yahoo.com](mailto:michael_s_campbell@yahoo.com)  
> > Newsgroups: comp.lang.ruby  
> > Subject: Re: raise unless RUBY\_VERSION[%r/^\s\*\d+.\d+/o].to\_f \>= 1.8
> > 
> > Ara.T.Howard wrote:
> > 
> > > any better methods of require a specific version/set of versions?
> > > 
> > > -a
> > 
> > This might be a good thing to encapsulate somehow; perl has a construct  
> > like so:
> > 
> > require 5;
> > 
> > which requires that the version of perl running the script be \>= 5.  
> > (IIRC, you can “require” arbitrary levels, like ``require 5.0.1;‘’, but  
> > I might be mistaken on that.)
> > 
> > Given ruby is changing in fairly large chunks, this might be useful.
> 
> –
> 
> ATTN: please update your address books with address below!
> 
> ===============================================================================
> 
> > EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov  
> > PHONE :: 303.497.6469  
> > ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328  
> > STP :: [Solar-Terrestrial Physics Data | NCEI](http://www.ngdc.noaa.gov/stp/)  
> > NGDC :: [http://www.ngdc.noaa.gov/](http://www.ngdc.noaa.gov/)  
> > NESDIS :: [http://www.nesdis.noaa.gov/](http://www.nesdis.noaa.gov/)  
> > NOAA :: [http://www.noaa.gov/](http://www.noaa.gov/)  
> > US DOC :: [http://www.commerce.gov/](http://www.commerce.gov/)
> > 
> > The difference between art and science is that science is what we  
> > understand well enough to explain to a computer.  
> > Art is everything else.  
> > – Donald Knuth, “Discover”
> > 
> > /bin/sh -c ‘for l in ruby perl;do $l -e “print "\x3a\x2d\x29\x0a"”;done’  
> > ===============================================================================

---

<div class="post-metadata">

**Author:** ![Ara.T.Howard2](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@Ara.T.Howard2](https://rubytalk.org/u/Ara.T.Howard2)\
**Post date:** [25 November 2003 04:42 UTC](https://rubytalk.org/t/raise-unless-ruby-version-r-s-d-d-o-to-f-1-8/9032/9 "2003-11-25T04:42:12Z")

</div>

i thought about this for a while and came up with a good reason not to do this

- but it currently eludes me!

unless someone can think of a reason not to - i’ll take it!

😉

-a

> **···**
>
> On Tue, 25 Nov 2003, Florian Gross wrote:
> 
> > Date: Tue, 25 Nov 2003 08:54:02 +0900  
> > From: Florian Gross [flgr@ccan.de](mailto:flgr@ccan.de)  
> > Newsgroups: comp.lang.ruby  
> > Subject: Re: raise unless RUBY\_VERSION[%r/^\s\*\d+.\d+/o].to\_f \>= 1.8
> > 
> > Moin!
> > 
> > Ara.T.Howard wrote:
> > 
> > > any better methods of require a specific version/set of versions?
> > 
> > What about RUBY\_VERSION \>= “1.8.0”?
> > 
> > Regards,  
> > Florian Gross
> 
> –
> 
> ATTN: please update your address books with address below!
> 
> ===============================================================================
> 
> > EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov  
> > PHONE :: 303.497.6469  
> > ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328  
> > STP :: [Solar-Terrestrial Physics Data | NCEI](http://www.ngdc.noaa.gov/stp/)  
> > NGDC :: [http://www.ngdc.noaa.gov/](http://www.ngdc.noaa.gov/)  
> > NESDIS :: [http://www.nesdis.noaa.gov/](http://www.nesdis.noaa.gov/)  
> > NOAA :: [http://www.noaa.gov/](http://www.noaa.gov/)  
> > US DOC :: [http://www.commerce.gov/](http://www.commerce.gov/)
> > 
> > The difference between art and science is that science is what we  
> > understand well enough to explain to a computer.  
> > Art is everything else.  
> > – Donald Knuth, “Discover”
> > 
> > /bin/sh -c ‘for l in ruby perl;do $l -e “print "\x3a\x2d\x29\x0a"”;done’  
> > ===============================================================================

---

<div class="post-metadata">

**Author:** ![Ara.T.Howard2](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@Ara.T.Howard2](https://rubytalk.org/u/Ara.T.Howard2)\
**Post date:** [26 November 2003 23:12 UTC](https://rubytalk.org/t/raise-unless-ruby-version-r-s-d-d-o-to-f-1-8/9032/10 "2003-11-26T23:12:26Z")

</div>

nice! you win paul!

-a

> **···**
>
> On Thu, 27 Nov 2003, Paul Brannan wrote:
> 
> > Date: Thu, 27 Nov 2003 06:40:52 +0900  
> > From: Paul Brannan [pbrannan@atdesk.com](mailto:pbrannan@atdesk.com)  
> > Newsgroups: comp.lang.ruby  
> > Subject: Re: raise unless RUBY\_VERSION[%r/^\s\*\d+.\d+/o].to\_f \>= 1.8
> > 
> > On Tue, Nov 25, 2003 at 08:32:14AM +0900, Ara.T.Howard wrote:
> > 
> > > any better methods of require a specific version/set of versions?
> > 
> > require ‘rbconfig’
> > 
> > major = Config::CONFIG[‘MAJOR’].to\_i  
> > minor = Config::CONFIG[‘MINOR’].to\_i  
> > teeny = Config::CONFIG[‘TEENY’].to\_i  
> > if major \< 1 or (major == 1 and minor \< 8) then  
> > raise “wrong version”  
> > end
> > 
> > Of course, this can be wrapped into a nice version class. I wrote one  
> > of these a long time ago and never released it, but there are plenty of  
> > others already out there.
> > 
> > Paul
> 
> –
> 
> ATTN: please update your address books with address below!
> 
> ===============================================================================
> 
> > EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov  
> > PHONE :: 303.497.6469  
> > ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328  
> > STP :: [Solar-Terrestrial Physics Data | NCEI](http://www.ngdc.noaa.gov/stp/)  
> > NGDC :: [http://www.ngdc.noaa.gov/](http://www.ngdc.noaa.gov/)  
> > NESDIS :: [http://www.nesdis.noaa.gov/](http://www.nesdis.noaa.gov/)  
> > NOAA :: [http://www.noaa.gov/](http://www.noaa.gov/)  
> > US DOC :: [http://www.commerce.gov/](http://www.commerce.gov/)
> > 
> > The difference between art and science is that science is what we  
> > understand well enough to explain to a computer.  
> > Art is everything else.  
> > – Donald Knuth, “Discover”
> > 
> > /bin/sh -c ‘for l in ruby perl;do $l -e “print "\x3a\x2d\x29\x0a"”;done’  
> > ===============================================================================

---

<div class="post-metadata">

**Author:** ![Gennady](https://avatars.discourse-cdn.com/v4/letter/g/6bbea6/32.png) [@Gennady](https://rubytalk.org/u/Gennady)\
**Post date:** [25 November 2003 05:56 UTC](https://rubytalk.org/t/raise-unless-ruby-version-r-s-d-d-o-to-f-1-8/9032/11 "2003-11-25T05:56:03Z")

</div>

> > Date: Tue, 25 Nov 2003 08:54:02 +0900  
> > From: Florian Gross [flgr@ccan.de](mailto:flgr@ccan.de)  
> > Newsgroups: comp.lang.ruby  
> > Subject: Re: raise unless RUBY\_VERSION[%r/^\s\*\d+.\d+/o].to\_f \>= 1.8
> > 
> > Moin!
> > 
> > Ara.T.Howard wrote:
> > 
> > > any better methods of require a specific version/set of versions?
> > 
> > What about RUBY\_VERSION \>= “1.8.0”?
> > 
> > Regards,  
> > Florian Gross
> 
> i thought about this for a while and came up with a good reason not to  
> do this
> 
> - but it currently eludes me!
> 
> unless someone can think of a reason not to - i’ll take it!

It does not work as a general solution, as “1.11.0” \< “1.8.0”. However,  
bearing in mind that Ruby so far had only 1-digit version components  
and 1.9.x is going to be the last Ruby1 version (according to Matz),  
this check may be OK.

Gennady

> **···**
>
> On Nov 24, 2003, at 20:42, Ara.T.Howard wrote:
> 
> > On Tue, 25 Nov 2003, Florian Gross wrote:
> 
> > 😉
> > 
> > ## -a
> > 
> > ATTN: please update your address books with address below!
> > 
> > # =======================================================================
> > 
> > > EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov  
> > > PHONE :: 303.497.6469  
> > > ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328  
> > > STP :: [Solar-Terrestrial Physics Data | NCEI](http://www.ngdc.noaa.gov/stp/)  
> > > NGDC :: [http://www.ngdc.noaa.gov/](http://www.ngdc.noaa.gov/)  
> > > NESDIS :: [http://www.nesdis.noaa.gov/](http://www.nesdis.noaa.gov/)  
> > > NOAA :: [http://www.noaa.gov/](http://www.noaa.gov/)  
> > > US DOC :: [http://www.commerce.gov/](http://www.commerce.gov/)
> > > 
> > > The difference between art and science is that science is what we  
> > > understand well enough to explain to a computer.  
> > > Art is everything else.  
> > > – Donald Knuth, “Discover”
> > > 
> > > /bin/sh -c ‘for l in ruby perl;do $l -e “print  
> > > "\x3a\x2d\x29\x0a"”;done’  
> > > =======================================================================  
> > > ========

---

<div class="post-metadata">

**Author:** ![daz](https://avatars.discourse-cdn.com/v4/letter/d/87869e/32.png) [@daz](https://rubytalk.org/u/daz)\
**Post date:** [25 November 2003 07:07 UTC](https://rubytalk.org/t/raise-unless-ruby-version-r-s-d-d-o-to-f-1-8/9032/12 "2003-11-25T07:07:12Z")

</div>

> > Ara.T.Howard wrote:
> > 
> > > any better methods of require a specific version/set of versions?
> > 
> > What about RUBY\_VERSION \>= “1.8.0”?
> 
> i thought about this for a while and came up with a good reason not to do this
> 
> - but it currently eludes me!

Maybe this bothered you ?

RUBY\_VERSION = “1.8.1”  
p RUBY\_VERSION \>= “1.8” #-\> true  
RUBY\_VERSION = “1.10.1”  
p RUBY\_VERSION \>= “1.8” #-\> false

… but MINOR 10 would upset RUBY\_VERSION\_CODE (in version.h)  
which, incidentally, would be a useful global (eventually).

It might take the pressure off Matz if 1.9 didn’t have to be  
followed by 2.0 tho’ 🙂

> unless someone can think of a reason not to - i’ll take it!

Um, because it’s crufty (looks like we can’t tell the difference  
between Numeric and String sorting sequence - even though I’ve  
seen it used a lot in Ruby).

daz

> **···**
>
> “Ara.T.Howard” [ahoward@ngdc.noaa.gov](mailto:ahoward@ngdc.noaa.gov) wrote:
> 
> > On Tue, 25 Nov 2003, Florian Gross wrote:

---

<div class="post-metadata">

**Author:** ![T\_Onoma](https://avatars.discourse-cdn.com/v4/letter/t/c2a13f/32.png) [@T\_Onoma](https://rubytalk.org/u/T_Onoma)\
**Post date:** [27 November 2003 05:59 UTC](https://rubytalk.org/t/raise-unless-ruby-version-r-s-d-d-o-to-f-1-8/9032/13 "2003-11-27T05:59:58Z")

</div>

not knocking paul’s solution or anything, but you prefer this to using a  
tuple?

> **···**
>
> On Thursday 27 November 2003 12:12 am, Ara.T.Howard wrote:
> 
> > On Thu, 27 Nov 2003, Paul Brannan wrote:
> > 
> > > Date: Thu, 27 Nov 2003 06:40:52 +0900  
> > > From: Paul Brannan [pbrannan@atdesk.com](mailto:pbrannan@atdesk.com)  
> > > Newsgroups: comp.lang.ruby  
> > > Subject: Re: raise unless RUBY\_VERSION[%r/^\s\*\d+.\d+/o].to\_f \>= 1.8
> > > 
> > > On Tue, Nov 25, 2003 at 08:32:14AM +0900, Ara.T.Howard wrote:
> > > 
> > > > any better methods of require a specific version/set of versions?
> > > 
> > > require ‘rbconfig’
> > > 
> > > major = Config::CONFIG[‘MAJOR’].to\_i  
> > > minor = Config::CONFIG[‘MINOR’].to\_i  
> > > teeny = Config::CONFIG[‘TEENY’].to\_i  
> > > if major \< 1 or (major == 1 and minor \< 8) then  
> > > raise “wrong version”  
> > > end
> > > 
> > > Of course, this can be wrapped into a nice version class. I wrote one  
> > > of these a long time ago and never released it, but there are plenty of  
> > > others already out there.
> > > 
> > > Paul
> > 
> > nice! you win paul!

---

<div class="post-metadata">

**Author:** ![T\_Onoma](https://avatars.discourse-cdn.com/v4/letter/t/c2a13f/32.png) [@T\_Onoma](https://rubytalk.org/u/T_Onoma)\
**Post date:** [25 November 2003 08:07 UTC](https://rubytalk.org/t/raise-unless-ruby-version-r-s-d-d-o-to-f-1-8/9032/14 "2003-11-25T08:07:57Z")

</div>

Any one think Ruby needs a Tuple class?

-t0

> **···**
>
> On Tuesday 25 November 2003 08:07 am, daz wrote:
> 
> > RUBY\_VERSION = “1.8.1”  
> > p RUBY\_VERSION \>= “1.8” #-\> true  
> > RUBY\_VERSION = “1.10.1”  
> > p RUBY\_VERSION \>= “1.8” #-\> false
> > 
> > … but MINOR 10 would upset RUBY\_VERSION\_CODE (in version.h)  
> > which, incidentally, would be a useful global (eventually).
> > 
> > It might take the pressure off Matz if 1.9 didn’t have to be  
> > followed by 2.0 tho’ 🙂
> > 
> > > unless someone can think of a reason not to - i’ll take it!
> > 
> > Um, because it’s crufty (looks like we can’t tell the difference  
> > between Numeric and String sorting sequence - even though I’ve  
> > seen it used a lot in Ruby).

---

<div class="post-metadata">

**Author:** ![Ara.T.Howard2](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@Ara.T.Howard2](https://rubytalk.org/u/Ara.T.Howard2)\
**Post date:** [25 November 2003 09:27 UTC](https://rubytalk.org/t/raise-unless-ruby-version-r-s-d-d-o-to-f-1-8/9032/15 "2003-11-25T09:27:12Z")

</div>

ah yes - _did_ think of that at one point. must have drank more coffee that  
day. thatnks for the heads up. definitely best to stick with a ‘to\_f’ type  
impl for now.

it would be really good if there was a ‘standard’ way to do this.

at one point, i created a Version class which used the rules that ‘ld’  
follows:

interface.age.revision

etc. etc.

does anyone know what the meaning of ruby’s tripplet?

-a

> **···**
>
> On Tue, 25 Nov 2003, Gennady wrote:
> 
> > Date: Tue, 25 Nov 2003 14:56:03 +0900  
> > From: Gennady [bystr@mac.com](mailto:bystr@mac.com)  
> > Newsgroups: comp.lang.ruby  
> > Subject: Re: raise unless RUBY\_VERSION[%r/^\s\*\d+.\d+/o].to\_f \>= 1.8
> > 
> > On Nov 24, 2003, at 20:42, Ara.T.Howard wrote:
> > 
> > > On Tue, 25 Nov 2003, Florian Gross wrote:
> > > 
> > > > Date: Tue, 25 Nov 2003 08:54:02 +0900  
> > > > From: Florian Gross [flgr@ccan.de](mailto:flgr@ccan.de)  
> > > > Newsgroups: comp.lang.ruby  
> > > > Subject: Re: raise unless RUBY\_VERSION[%r/^\s\*\d+.\d+/o].to\_f \>= 1.8
> > > > 
> > > > Moin!
> > > > 
> > > > Ara.T.Howard wrote:
> > > > 
> > > > > any better methods of require a specific version/set of versions?
> > > > 
> > > > What about RUBY\_VERSION \>= “1.8.0”?
> > > > 
> > > > Regards,  
> > > > Florian Gross
> > > 
> > > i thought about this for a while and came up with a good reason not to  
> > > do this
> > > 
> > > - but it currently eludes me!
> > > 
> > > unless someone can think of a reason not to - i’ll take it!
> > 
> > It does not work as a general solution, as “1.11.0” \< “1.8.0”. However,  
> > bearing in mind that Ruby so far had only 1-digit version components  
> > and 1.9.x is going to be the last Ruby1 version (according to Matz),  
> > this check may be OK.
> 
> –
> 
> ATTN: please update your address books with address below!
> 
> ===============================================================================
> 
> > EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov  
> > PHONE :: 303.497.6469  
> > ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328  
> > STP :: [Solar-Terrestrial Physics Data | NCEI](http://www.ngdc.noaa.gov/stp/)  
> > NGDC :: [http://www.ngdc.noaa.gov/](http://www.ngdc.noaa.gov/)  
> > NESDIS :: [http://www.nesdis.noaa.gov/](http://www.nesdis.noaa.gov/)  
> > NOAA :: [http://www.noaa.gov/](http://www.noaa.gov/)  
> > US DOC :: [http://www.commerce.gov/](http://www.commerce.gov/)
> > 
> > The difference between art and science is that science is what we  
> > understand well enough to explain to a computer.  
> > Art is everything else.  
> > – Donald Knuth, “Discover”
> > 
> > /bin/sh -c ‘for l in ruby perl;do $l -e “print "\x3a\x2d\x29\x0a"”;done’  
> > ===============================================================================

---

<div class="post-metadata">

**Author:** ![Ara.T.Howard2](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@Ara.T.Howard2](https://rubytalk.org/u/Ara.T.Howard2)\
**Post date:** [27 November 2003 16:52 UTC](https://rubytalk.org/t/raise-unless-ruby-version-r-s-d-d-o-to-f-1-8/9032/16 "2003-11-27T16:52:14Z")

</div>

yes. one thing i had not yet mentioned is that i also may want to incorporate  
the semantics of version. for instance, with libtool type versioning, the  
following are compatible versions:

7.6.10  
2.0.7

this is because, with libtool, the revision’s meaning is

revision.age.impl

(see the libtool docs for more)

because revision 7 spans 6 ages, it is compatible with all versions 1 - 7.

i don’t know what ruby’s major, minor, teeny numbers mean but would like to do  
something similar if possible. and using them in paul’s way would make the  
intent very clear.

-a

> **···**
>
> On Thu, 27 Nov 2003, T. Onoma wrote:
> 
> > Date: Thu, 27 Nov 2003 14:59:58 +0900  
> > From: T. Onoma [transami@runbox.com](mailto:transami@runbox.com)  
> > Newsgroups: comp.lang.ruby  
> > Subject: Re: raise unless RUBY\_VERSION[%r/^\s\*\d+.\d+/o].to\_f \>= 1.8
> > 
> > On Thursday 27 November 2003 12:12 am, Ara.T.Howard wrote:
> > 
> > > On Thu, 27 Nov 2003, Paul Brannan wrote:
> > > 
> > > > Date: Thu, 27 Nov 2003 06:40:52 +0900  
> > > > From: Paul Brannan [pbrannan@atdesk.com](mailto:pbrannan@atdesk.com)  
> > > > Newsgroups: comp.lang.ruby  
> > > > Subject: Re: raise unless RUBY\_VERSION[%r/^\s\*\d+.\d+/o].to\_f \>= 1.8
> > > > 
> > > > On Tue, Nov 25, 2003 at 08:32:14AM +0900, Ara.T.Howard wrote:
> > > > 
> > > > > any better methods of require a specific version/set of versions?
> > > > 
> > > > require ‘rbconfig’
> > > > 
> > > > major = Config::CONFIG[‘MAJOR’].to\_i  
> > > > minor = Config::CONFIG[‘MINOR’].to\_i  
> > > > teeny = Config::CONFIG[‘TEENY’].to\_i  
> > > > if major \< 1 or (major == 1 and minor \< 8) then  
> > > > raise “wrong version”  
> > > > end
> > > > 
> > > > Of course, this can be wrapped into a nice version class. I wrote one  
> > > > of these a long time ago and never released it, but there are plenty of  
> > > > others already out there.
> > > > 
> > > > Paul
> > > 
> > > nice! you win paul!
> > 
> > not knocking paul’s solution or anything, but you prefer this to using a  
> > tuple?
> 
> –
> 
> ATTN: please update your address books with address below!
> 
> ===============================================================================
> 
> > EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov  
> > PHONE :: 303.497.6469  
> > ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328  
> > STP :: [Solar-Terrestrial Physics Data | NCEI](http://www.ngdc.noaa.gov/stp/)  
> > NGDC :: [http://www.ngdc.noaa.gov/](http://www.ngdc.noaa.gov/)  
> > NESDIS :: [http://www.nesdis.noaa.gov/](http://www.nesdis.noaa.gov/)  
> > NOAA :: [http://www.noaa.gov/](http://www.noaa.gov/)  
> > US DOC :: [http://www.commerce.gov/](http://www.commerce.gov/)
> > 
> > The difference between art and science is that science is what we  
> > understand well enough to explain to a computer.  
> > Art is everything else.  
> > – Donald Knuth, “Discover”
> > 
> > /bin/sh -c ‘for l in ruby perl;do $l -e “print "\x3a\x2d\x29\x0a"”;done’  
> > ===============================================================================

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://rubytalk.org/u/Robert)\
**Post date:** [25 November 2003 09:07 UTC](https://rubytalk.org/t/raise-unless-ruby-version-r-s-d-d-o-to-f-1-8/9032/17 "2003-11-25T09:07:12Z")

</div>

“T. Onoma” [transami@runbox.com](mailto:transami@runbox.com) schrieb im Newsbeitrag  
[news:200311250002.09555.transami@runbox.com](mailto:news:200311250002.09555.transami@runbox.com)…

> **···**
>
> > On Tuesday 25 November 2003 08:07 am, daz wrote:
> > 
> > > RUBY\_VERSION = “1.8.1”  
> > > p RUBY\_VERSION \>= “1.8” #-\> true  
> > > RUBY\_VERSION = “1.10.1”  
> > > p RUBY\_VERSION \>= “1.8” #-\> false
> > > 
> > > … but MINOR 10 would upset RUBY\_VERSION\_CODE (in version.h)  
> > > which, incidentally, would be a useful global (eventually).
> > > 
> > > It might take the pressure off Matz if 1.9 didn’t have to be  
> > > followed by 2.0 tho’ 🙂
> > > 
> > > > unless someone can think of a reason not to - i’ll take it!
> > > 
> > > Um, because it’s crufty (looks like we can’t tell the difference  
> > > between Numeric and String sorting sequence - even though I’ve  
> > > seen it used a lot in Ruby).
> > 
> > Any one think Ruby needs a Tuple class?
> 
> It’s already there: Array.
> 
> ```
> robert
> 
> ```

---

<div class="post-metadata">

**Author:** ![Chad\_Fowler](https://avatars.discourse-cdn.com/v4/letter/c/5daacb/32.png) [@Chad\_Fowler](https://rubytalk.org/u/Chad_Fowler)\
**Post date:** [25 November 2003 11:21 UTC](https://rubytalk.org/t/raise-unless-ruby-version-r-s-d-d-o-to-f-1-8/9032/18 "2003-11-25T11:21:20Z")

</div>

# On Tue, 25 Nov 2003, Gennady wrote:

> **···**
>
> On Tue, 25 Nov 2003, Ara.T.Howard wrote:
> 
> # 
> 
> # \> Date: Tue, 25 Nov 2003 14:56:03 +0900
> 
> # \> From: Gennady [bystr@mac.com](mailto:bystr@mac.com)
> 
> # \> Newsgroups: comp.lang.ruby
> 
> # \> Subject: Re: raise unless RUBY\_VERSION[%r/^\s\*\d+.\d+/o].to\_f \>= 1.8
> 
> # \>
> 
> # \>
> 
> # \>
> 
> # \> On Nov 24, 2003, at 20:42, Ara.T.Howard wrote:
> 
> # \>
> 
> # \> \> On Tue, 25 Nov 2003, Florian Gross wrote:
> 
> # \> \>
> 
> # \> \>\> Date: Tue, 25 Nov 2003 08:54:02 +0900
> 
> # \> \>\> From: Florian Gross [flgr@ccan.de](mailto:flgr@ccan.de)
> 
> # \> \>\> Newsgroups: comp.lang.ruby
> 
> # \> \>\> Subject: Re: raise unless RUBY\_VERSION[%r/^\s\*\d+.\d+/o].to\_f \>= 1.8
> 
> # \> \>\>
> 
> # \> \>\> Moin!
> 
> # \> \>\>
> 
> # \> \>\> Ara.T.Howard wrote:
> 
> # \> \>\>
> 
> # \> \>\>\> any better methods of require a specific version/set of versions?
> 
> # \> \>\>
> 
> # \> \>\> What about RUBY\_VERSION \>= “1.8.0”?
> 
> # \> \>\>
> 
> # \> \>\> Regards,
> 
> # \> \>\> Florian Gross
> 
> # \> \>
> 
> # \> \> i thought about this for a while and came up with a good reason not to
> 
> # \> \> do this
> 
> # \> \> - but it currently eludes me!
> 
> # \> \>
> 
> # \> \> unless someone can think of a reason not to - i’ll take it!
> 
> # \>
> 
> # \> It does not work as a general solution, as “1.11.0” \< “1.8.0”. However,
> 
> # \> bearing in mind that Ruby so far had only 1-digit version components
> 
> # \> and 1.9.x is going to be the last Ruby1 version (according to Matz),
> 
> # \> this check may be OK.
> 
> # 
> 
> # ah yes - _did_ think of that at one point. must have drank more coffee that
> 
> # day. thatnks for the heads up. definitely best to stick with a ‘to\_f’ type
> 
> # impl for now.
> 
> # 
> 
> # it would be really good if there was a ‘standard’ way to do this.
> 
> # 
> 
> # at one point, i created a Version class which used the rules that ‘ld’
> 
> # follows:
> 
> # 
> 
> # interface.age.revision
> 
> # 
> 
> # etc. etc.
> 
> # 
> 
> See my previous post about the Version class from RubyGems. It handles  
> the cases that you need.
> 
> Chad

---

<div class="post-metadata">

**Author:** ![Sabbyxtabby](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@Sabbyxtabby](https://rubytalk.org/u/Sabbyxtabby)\
**Post date:** [25 November 2003 20:07 UTC](https://rubytalk.org/t/raise-unless-ruby-version-r-s-d-d-o-to-f-1-8/9032/19 "2003-11-25T20:07:11Z")

</div>

Unfortunately, ‘to\_f’ suffers the same problem, since 1.11 \< 1.8.  
Numerically compare each part of version string:

require ‘scanf.rb’  
raise unless (RUBY\_VERSION.scanf(“%d.%d.%d”) \<=\> [1,8]) \>= 0

> **···**
>
> “Ara.T.Howard” [ahoward@ngdc.noaa.gov](mailto:ahoward@ngdc.noaa.gov) wrote:
> 
> > On Tue, 25 Nov 2003, Gennady wrote:
> > 
> > > > On Tue, 25 Nov 2003, Florian Gross wrote:
> > > > 
> > > > > What about RUBY\_VERSION \>= “1.8.0”?
> > > 
> > > It does not work as a general solution, as “1.11.0” \< “1.8.0”.
> > 
> > ah yes - _did_ think of that at one point. must have drank more coffee that  
> > day. thatnks for the heads up. definitely best to stick with a ‘to\_f’ type  
> > impl for now.

---

<div class="post-metadata">

**Author:** ![T\_Onoma](https://avatars.discourse-cdn.com/v4/letter/t/c2a13f/32.png) [@T\_Onoma](https://rubytalk.org/u/T_Onoma)\
**Post date:** [25 November 2003 09:51 UTC](https://rubytalk.org/t/raise-unless-ruby-version-r-s-d-d-o-to-f-1-8/9032/20 "2003-11-25T09:51:00Z")

</div>

No,

class Tuple \< Array  
include Comparable  
end

class Array  
def to\_t  
return Tuple.new(self)  
end  
end

Now is has a Tuple. Try,

ruby\_version = RUBY\_VERSION.split(‘.’).collect { |i| i.to\_i }.to\_t

puts ruby\_version  
puts ruby\_version \>= [1,7,1]  
puts ruby\_version \>= [1,8]  
puts ruby\_version \>= [1,8,1]  
puts ruby\_version \>= [1,10]

Although a Tuple a.b.c … literal would look better.

-t0

> **···**
>
> On Tuesday 25 November 2003 10:07 am, Robert Klemme wrote:
> 
> > “T. Onoma” [transami@runbox.com](mailto:transami@runbox.com) schrieb im Newsbeitrag  
> > [news:200311250002.09555.transami@runbox.com](mailto:news:200311250002.09555.transami@runbox.com)…
> > 
> > > On Tuesday 25 November 2003 08:07 am, daz wrote:
> > > 
> > > > RUBY\_VERSION = “1.8.1”  
> > > > p RUBY\_VERSION \>= “1.8” #-\> true  
> > > > RUBY\_VERSION = “1.10.1”  
> > > > p RUBY\_VERSION \>= “1.8” #-\> false
> > > > 
> > > > … but MINOR 10 would upset RUBY\_VERSION\_CODE (in version.h)  
> > > > which, incidentally, would be a useful global (eventually).
> > > > 
> > > > It might take the pressure off Matz if 1.9 didn’t have to be  
> > > > followed by 2.0 tho’ 🙂
> > > > 
> > > > > unless someone can think of a reason not to - i’ll take it!
> > > > 
> > > > Um, because it’s crufty (looks like we can’t tell the difference  
> > > > between Numeric and String sorting sequence - even though I’ve  
> > > > seen it used a lot in Ruby).
> > > 
> > > Any one think Ruby needs a Tuple class?
> > 
> > It’s already there: Array.

[Next page](https://rubytalk.org/t/raise-unless-ruby-version-r-s-d-d-o-to-f-1-8/9032.md?page=2)
