# Meaningful RUBY\_VERSION#\<=\>

**URL:** <https://www.ruby-forum.com/t/meaningful-ruby-version/100470>\
**Category:** Ruby\
**Created:** [February 2, 2006, 9:30pm UTC](https://www.ruby-forum.com/t/meaningful-ruby-version/100470 "2006-02-02T21:30:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 2, 2006, 9:30pm UTC](https://www.ruby-forum.com/t/meaningful-ruby-version/100470/1 "2006-02-02T21:30:11Z")

</div>

i’m sure something much more elegant could be made, but this summarizes  
desired  
behaviour.

harp:~ \> cat a.rb  
class RubyVersion \< ::String  
include Comparable  
def \<=\> other  
components \<=\> RubyVersion::new(other).components  
end  
def components  
scan(%r/\d+/).map{|c| Integer c}  
end  
def major  
components[0]  
end  
def minor  
components[1]  
end  
def tiny  
components[2]  
end  
module ::Kernel  
def RubyVersion \*a, &b  
RubyVersion::new \*a, &b  
end  
v = $VERBOSE  
$VERBOSE = nil  
::RUBY\_VERSION = RubyVersion(::RUBY\_VERSION)  
$VERBOSE = v  
end  
end

p RUBY\_VERSION  
p RUBY\_VERSION \> “1.8.3”  
p RUBY\_VERSION \> “1.9.0”

harp:~ \> ruby a.rb  
“1.8.4”  
true  
false

kind regards.

-a

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 2, 2006, 10:09pm UTC](https://www.ruby-forum.com/t/meaningful-ruby-version/100470/2 "2006-02-02T22:09:31Z")

</div>

On Fri, Feb 03, 2006 at 05:29:10AM +0900, Ara.T.Howard wrote:

> p RUBY\_VERSION  
> p RUBY\_VERSION \> “1.8.3”  
> p RUBY\_VERSION \> “1.9.0”
> 
> harp:~ \> ruby a.rb  
> “1.8.4”  
> true  
> false

matz has said that 1.8.10 (or more generally versions with 2 digits in  
one  
of the components) will not happen. Isn’t String#\<=\> enough? (unless you  
absolutely want major, minor & tiny)

On a stock install:

RUBY\_VERSION # =\> “1.8.4”  
RUBY\_VERSION \> “1.8.3” # =\> true  
RUBY\_VERSION \> “1.9.0” # =\> false

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 2, 2006, 10:33pm UTC](https://www.ruby-forum.com/t/meaningful-ruby-version/100470/3 "2006-02-02T22:33:39Z")

</div>

On Fri, 3 Feb 2006, Mauricio F. wrote:

> > end  
> > matz has said that 1.8.10 (or more generally versions with 2 digits in one  
> > of the components) will not happen. Isn’t String#\<=\> enough? (unless you  
> > absolutely want major, minor & tiny)
> 
> On a stock install:
> 
> RUBY\_VERSION # =\> “1.8.4”  
> RUBY\_VERSION \> “1.8.3” # =\> true  
> RUBY\_VERSION \> “1.9.0” # =\> false

maybe so then - i did not know about the 2 digit restriction. thanks!

-a

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 3, 2006, 2:05pm UTC](https://www.ruby-forum.com/t/meaningful-ruby-version/100470/4 "2006-02-03T14:05:28Z")

</div>

Mauricio F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> matz has said that 1.8.10 (or more generally versions with 2 digits in one  
> of the components) will not happen.

Aww… I was really looking forward to ruby 10.0 ☹
