I already found a solution for \"Most unixes\" via cat /proc/cpuinfo
, but a pure-Ruby solution would be nicer.
Combination of @grosser's and @paxdiablo's answer, since on my system (winxp) win32_computersystem doesn't have any processor info; this works though:
require 'win32ole'
wmi = WIN32OLE.connect("winmgmts://")
info = wmi.ExecQuery ("select NumberOfCores from Win32_processor")
puts info.to_enum.first.NumberOfCores
To see what's available on your system, run this from powershell (i used 1.0 in this case):
Get-WmiObject -list
(might want to pipe to grep if you've got cygwin installed)