blob: 69f87eade41d4b86d3f006d31f85ec91fa45c027 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
class Hardware
module CPU extend self
def type
@type || :dunno
end
def family
@family || :dunno
end
def cores
@cores || 1
end
def bits
@bits || 64
end
def is_32_bit?
bits == 32
end
def is_64_bit?
bits == 64
end
end
case RUBY_PLATFORM.downcase
when /darwin/
require 'os/mac/hardware'
CPU.extend MacCPUs
when /linux/
require 'os/linux/hardware'
CPU.extend LinuxCPUs
else
raise "The system `#{`uname`.chomp}' is not supported."
end
def self.cores_as_words
case Hardware.processor_count
when 1 then 'single'
when 2 then 'dual'
when 4 then 'quad'
else
Hardware.processor_count
end
end
end
|