I already found a solution for \"Most unixes\" via cat /proc/cpuinfo, but a pure-Ruby solution would be nicer.
Surely if you can cat it, you can open, read and close it using the standard features of the language without resorting to a system()-type call.
You may just need to detect what platform you're on dynamically and either:
/proc/cpuinfo "file" for Linux; orThat last line can use:
require 'win32ole'
wmi = WIN32OLE.connect("winmgmts://")
info = wmi.ExecQuery ("select * from Win32_ComputerSystem")
Then use info's NumberOfProcessors item.