# Platform

**URL:** <https://www.ruby-forum.com/t/platform/178107>\
**Category:** IronRuby\
**Created:** [October 29, 2009, 8:25am UTC](https://www.ruby-forum.com/t/platform/178107 "2009-10-29T08:25:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![confundido](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/90ced4/32.png) [@confundido](https://www.ruby-forum.com/u/confundido)\
**Post date:** [October 29, 2009, 8:25am UTC](https://www.ruby-forum.com/t/platform/178107/1 "2009-10-29T08:25:46Z")

</div>

I noticed that the PLATFORM and RUBY\_PLATFORM constants returns the same  
string when running from MRI as from IronRuby. Is there a standard Ruby  
constant or Kernel method or something that will indicate that the  
interpreter is IronRuby as opposed to MRI? While it is certainly true  
that the OS is the same when running from both environments, it would  
seem pretty useful to me to be able to distinguish, as JRuby does, so we  
can write libraries that can selectively do things like selectively take  
advantage of the .NET BCL if present. There are probably easy enough  
ways to work around this, like ‘begin require System @platform=“ir”  
rescue LoadError end’ but using PLATFORM directly feels like it would be  
more elegant.

---

<div class="post-metadata">

**Author:** ![confundido](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/90ced4/32.png) [@confundido](https://www.ruby-forum.com/u/confundido)\
**Post date:** [October 29, 2009, 8:30am UTC](https://www.ruby-forum.com/t/platform/178107/2 "2009-10-29T08:30:27Z")

</div>

I use IRONRUBY\_VERSION

require ‘caricature/clr’ if defined?(IRONRUBY\_VERSION)

## But we do need to find a way to “fix” the rbconfig file because it would be good to interrogate that sometimes.

Met vriendelijke groeten - Best regards - Salutations  
Ivan Porto C.  
Blog: [http://flanders.co.nz](http://flanders.co.nz)  
Twitter: [http://twitter.com/casualjim](http://twitter.com/casualjim)  
Author of IronRuby in Action ([http://manning.com/carrero](http://manning.com/carrero))

On Thu, Oct 29, 2009 at 8:25 AM, Nathan Stults

---

<div class="post-metadata">

**Author:** ![confundido](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/90ced4/32.png) [@confundido](https://www.ruby-forum.com/u/confundido)\
**Post date:** [October 29, 2009, 8:29am UTC](https://www.ruby-forum.com/t/platform/178107/3 "2009-10-29T08:29:17Z")

</div>

You can use this construct:

> > > defined? RUBY\_ENGINE and RUBY\_ENGINE == “ironruby”  
> > > =\> true

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Nathan Stults  
Sent: Thursday, October 29, 2009 12:26 AM  
To: removed\_email\_address@domain.invalid  
Subject: [Ironruby-core] Platform

I noticed that the PLATFORM and RUBY\_PLATFORM constants returns the same  
string when running from MRI as from IronRuby. Is there a standard Ruby  
constant or Kernel method or something that will indicate that the  
interpreter is IronRuby as opposed to MRI? While it is certainly true  
that the OS is the same when running from both environments, it would  
seem pretty useful to me to be able to distinguish, as JRuby does, so we  
can write libraries that can selectively do things like selectively take  
advantage of the .NET BCL if present. There are probably easy enough  
ways to work around this, like ‘begin require System @platform=“ir”  
rescue LoadError end’ but using PLATFORM directly feels like it would be  
more elegant.

---

<div class="post-metadata">

**Author:** ![confundido](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/90ced4/32.png) [@confundido](https://www.ruby-forum.com/u/confundido)\
**Post date:** [October 29, 2009, 1:59pm UTC](https://www.ruby-forum.com/t/platform/178107/4 "2009-10-29T13:59:58Z")

</div>

Very nice, thank you

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Shri B.  
Sent: Thursday, October 29, 2009 12:29 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] Platform

You can use this construct:

> > > defined? RUBY\_ENGINE and RUBY\_ENGINE == “ironruby”

=\> true

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Nathan Stults  
Sent: Thursday, October 29, 2009 12:26 AM  
To: removed\_email\_address@domain.invalid  
Subject: [Ironruby-core] Platform

I noticed that the PLATFORM and RUBY\_PLATFORM constants returns the same  
string when running from MRI as from IronRuby. Is there a standard Ruby  
constant or Kernel method or something that will indicate that the  
interpreter is IronRuby as opposed to MRI? While it is certainly true  
that the OS is the same when running from both environments, it would  
seem pretty useful to me to be able to distinguish, as JRuby does, so we  
can write libraries that can selectively do things like selectively take  
advantage of the .NET BCL if present. There are probably easy enough  
ways to work around this, like ‘begin require System @platform=“ir”  
rescue LoadError end’ but using PLATFORM directly feels like it would be  
more elegant.
