In JRuby, you can just use java.lang.Runtime.get_runtime.available_processors. Is there anything available for MRI, perhaps using a gem implemented in C?
In a future release of Ruby, it would be nice to see this information available as a automatically defined top-level constant, like RUBY_PLATFORM and RUBY_VERSION.
So far there isn’t. But you can either use
parallelgem or take a look how it figures out the number of cores.