On Jan 15, 1:40 ¨Âí¬ ×áìôïî Èïïð¼÷áì®®®Àöùðåò®èïðôï®ïòç¾ ÷òïôåº > On 1/15/2010 9:36 AM, Walton Hoops wrote: > > > > > On 1/14/2010 4:12 PM, Iñáki Baz Castillo wrote: > >> Hi, is there a reliable way under Ruby to know the OS architecture > >> (32 or 64 > >> bits)? > > >> I've just found RUBY_PLATFORM constant which returns "x86_64-linux" > >> under 64 > >> bits, however it doesn't send very reliable for me. > > >> I need a way working under Linux and BSD. Thanks for any suggestion. > > > I can't vouch for how accurate it is, but an OS gem was recently > > announced on this list. > > gem install os > > > irb(main):001:0> require 'os' > > => true > > irb(main):002:0> OS.bits > > => 64 > > irb(main):004:0> OS.posix? > > => true > > irb(main):005:0> > > Hmm.. it does not appear to deal with 32-bit ruby running on a 64 bit > system though. > On my Windows 7 x64 (with 32-bit ruby): > irb(main):005:0> OS.bits > => 32 > irb(main):006:0> 1.size > => 4 > irb(main):007:0> No matter how many bits the OS has, as long the compiled interpreter is 32 bits, the returned values is going to be 32 bits. Windows can run 32bits applications along with 64bits ones, but that doesn't mean you can access 64bits address space or tools from 32bits applications. -- Luis Lavena