blob: ec13814cca75bbd07982ff4f006351f6d44d4cc0 (
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
 | require 'os'
class Hardware
  module CPU extend self
    INTEL_32BIT_ARCHS = [:i386].freeze
    INTEL_64BIT_ARCHS = [:x86_64].freeze
    PPC_32BIT_ARCHS   = [:ppc, :ppc7400, :ppc7450, :ppc970].freeze
    PPC_64BIT_ARCHS   = [:ppc64].freeze
    def type
      :dunno
    end
    def family
      :dunno
    end
    def cores
      1
    end
    def bits
      64
    end
    def is_32_bit?
      bits == 32
    end
    def is_64_bit?
      bits == 64
    end
    def intel?
      type == :intel
    end
    def ppc?
      type == :ppc
    end
    def features
      []
    end
    def feature?(name)
      features.include?(name)
    end
  end
  if OS.mac?
    require 'os/mac/hardware'
    CPU.extend MacCPUs
  elsif OS.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::CPU.cores
    when 1 then 'single'
    when 2 then 'dual'
    when 4 then 'quad'
    else
      Hardware::CPU.cores
    end
  end
  def self.oldest_cpu
    if Hardware::CPU.intel?
      if Hardware::CPU.is_64_bit?
        :core2
      else
        :core
      end
    else
      Hardware::CPU.family
    end
  end
end
 |