sys-cpu 1.0.1 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,15 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'win32ole'
2
4
  require 'socket'
3
5
 
4
- # See Ruby bugs #2618 and #7681. This is a workaround.
5
- BEGIN{
6
- require 'win32ole'
7
- if RUBY_VERSION.to_f < 2.0
8
- WIN32OLE.ole_initialize
9
- at_exit { WIN32OLE.ole_uninitialize }
10
- end
11
- }
12
-
13
6
  # The Sys module serves only as a namespace
14
7
  module Sys
15
8
  # Encapsulates system CPU information
@@ -17,10 +10,10 @@ module Sys
17
10
  # Error raised if any of the Sys::CPU methods fail.
18
11
  class Error < StandardError; end
19
12
 
20
- private
21
-
22
13
  # Base connect string
23
- BASE_CS = "winmgmts:{impersonationLevel=impersonate}" # :nodoc:
14
+ BASE_CS = 'winmgmts:{impersonationLevel=impersonate}' # :nodoc:
15
+
16
+ private_constant :BASE_CS
24
17
 
25
18
  # Fields used in the CPUStruct
26
19
  fields = %w[
@@ -71,21 +64,21 @@ module Sys
71
64
  ]
72
65
 
73
66
  # The struct returned by the CPU.processors method
74
- CPUStruct = Struct.new("CPUStruct", *fields) # :nodoc:
67
+ CPUStruct = Struct.new('CPUStruct', *fields) # :nodoc:
75
68
 
76
- public
69
+ private_constant :CPUStruct
77
70
 
78
71
  # Returns the +host+ CPU's architecture, or nil if it cannot be
79
72
  # determined.
80
73
  #
81
- def self.architecture(host=Socket.gethostname)
74
+ def self.architecture(host = Socket.gethostname)
82
75
  cs = BASE_CS + "//#{host}/root/cimv2:Win32_Processor='cpu0'"
83
76
  begin
84
77
  wmi = WIN32OLE.connect(cs)
85
- rescue WIN32OLERuntimeError => e
86
- raise Error, e
78
+ rescue WIN32OLERuntimeError => err
79
+ raise Error, err
87
80
  else
88
- self.get_cpu_arch(wmi.Architecture)
81
+ get_cpu_arch(wmi.Architecture)
89
82
  end
90
83
  end
91
84
 
@@ -98,10 +91,10 @@ module Sys
98
91
  cs = BASE_CS + "//#{host}/root/cimv2:Win32_Processor='cpu#{cpu_num}'"
99
92
  begin
100
93
  wmi = WIN32OLE.connect(cs)
101
- rescue WIN32OLERuntimeError => e
102
- raise Error, e
94
+ rescue WIN32OLERuntimeError => err
95
+ raise Error, err
103
96
  else
104
- return wmi.CurrentClockSpeed
97
+ wmi.CurrentClockSpeed
105
98
  end
106
99
  end
107
100
 
@@ -117,10 +110,10 @@ module Sys
117
110
  cs = BASE_CS + "//#{host}/root/cimv2:Win32_Processor='cpu#{cpu_num}'"
118
111
  begin
119
112
  wmi = WIN32OLE.connect(cs)
120
- rescue WIN32OLERuntimeError => e
121
- raise Error, e
113
+ rescue WIN32OLERuntimeError => err
114
+ raise Error, err
122
115
  else
123
- return wmi.LoadPercentage
116
+ wmi.LoadPercentage
124
117
  end
125
118
  end
126
119
 
@@ -130,10 +123,10 @@ module Sys
130
123
  cs = BASE_CS + "//#{host}/root/cimv2:Win32_Processor='cpu0'"
131
124
  begin
132
125
  wmi = WIN32OLE.connect(cs)
133
- rescue WIN32OLERuntimeError => e
134
- raise Error, e
126
+ rescue WIN32OLERuntimeError => err
127
+ raise Error, err
135
128
  else
136
- return wmi.Name
129
+ wmi.Name
137
130
  end
138
131
  end
139
132
 
@@ -145,10 +138,10 @@ module Sys
145
138
  cs = BASE_CS + "//#{host}/root/cimv2:Win32_ComputerSystem='#{host}'"
146
139
  begin
147
140
  wmi = WIN32OLE.connect(cs)
148
- rescue WIN32OLERuntimeError => e
149
- raise Error, e
141
+ rescue WIN32OLERuntimeError => err
142
+ raise Error, err
150
143
  else
151
- return wmi.NumberOfProcessors
144
+ wmi.NumberOfProcessors
152
145
  end
153
146
  end
154
147
 
@@ -201,20 +194,21 @@ module Sys
201
194
  # * voltage_caps
202
195
  #
203
196
  # Note that not all of these members will necessarily be defined.
204
- #
197
+ #--
198
+ # rubocop:disable Metrics/BlockLength
205
199
  def self.processors(host = Socket.gethostname) # :yields: CPUStruct
206
200
  begin
207
201
  wmi = WIN32OLE.connect(BASE_CS + "//#{host}/root/cimv2")
208
- rescue WIN32OLERuntimeError => e
209
- raise Error, e
202
+ rescue WIN32OLERuntimeError => err
203
+ raise Error, err
210
204
  else
211
- wmi.InstancesOf("Win32_Processor").each{ |cpu|
205
+ wmi.InstancesOf('Win32_Processor').each do |cpu|
212
206
  yield CPUStruct.new(
213
207
  cpu.AddressWidth,
214
- self.get_cpu_arch(cpu.Architecture),
215
- self.get_availability(cpu.Availability),
208
+ get_cpu_arch(cpu.Architecture),
209
+ get_availability(cpu.Availability),
216
210
  cpu.Caption,
217
- self.get_cmec(cpu.ConfigManagerErrorCode),
211
+ get_cmec(cpu.ConfigManagerErrorCode),
218
212
  cpu.ConfigManagerUserConfig,
219
213
  get_status(cpu.CpuStatus),
220
214
  cpu.CreationClassName,
@@ -226,7 +220,7 @@ module Sys
226
220
  cpu.ErrorCleared,
227
221
  cpu.ErrorDescription,
228
222
  cpu.ExtClock,
229
- self.get_family(cpu.Family),
223
+ get_family(cpu.Family),
230
224
  cpu.InstallDate,
231
225
  cpu.L2CacheSize,
232
226
  cpu.L2CacheSpeed,
@@ -241,7 +235,7 @@ module Sys
241
235
  cpu.PowerManagementSupported,
242
236
  cpu.PowerManagementCapabilities,
243
237
  cpu.ProcessorId,
244
- self.get_processor_type(cpu.ProcessorType),
238
+ get_processor_type(cpu.ProcessorType),
245
239
  cpu.Revision,
246
240
  cpu.Role,
247
241
  cpu.SocketDesignation,
@@ -251,24 +245,26 @@ module Sys
251
245
  cpu.SystemCreationClassName,
252
246
  cpu.SystemName,
253
247
  cpu.UniqueId,
254
- self.get_upgrade_method(cpu.UpgradeMethod),
248
+ get_upgrade_method(cpu.UpgradeMethod),
255
249
  cpu.Version,
256
- self.get_voltage_caps(cpu.VoltageCaps)
250
+ get_voltage_caps(cpu.VoltageCaps)
257
251
  )
258
- }
252
+ end
259
253
  end
260
254
  end
261
255
 
256
+ # rubocop:enable Metrics/BlockLength
257
+
262
258
  # Returns a string indicating the type of processor, e.g. GenuineIntel.
263
259
  #
264
260
  def self.cpu_type(host = Socket.gethostname)
265
261
  cs = BASE_CS + "//#{host}/root/cimv2:Win32_Processor='cpu0'"
266
262
  begin
267
263
  wmi = WIN32OLE.connect(cs)
268
- rescue WIN32OLERuntimeError => e
269
- raise Error, e
264
+ rescue WIN32OLERuntimeError => err
265
+ raise Error, err
270
266
  else
271
- return wmi.Manufacturer
267
+ wmi.Manufacturer
272
268
  end
273
269
  end
274
270
 
@@ -280,517 +276,640 @@ module Sys
280
276
  def self.get_cmec(num)
281
277
  case num
282
278
  when 0
283
- str = "The device is working properly."
284
- return str
279
+ 'The device is working properly.'
285
280
  when 1
286
- str = "The device is not configured correctly."
287
- return str
281
+ 'The device is not configured correctly.'
288
282
  when 2
289
- str = "Windows cannot load the driver for the device."
290
- return str
283
+ 'Windows cannot load the driver for the device.'
291
284
  when 3
292
- str = "The driver for the device might be corrupted, or the"
293
- str << " system may be running low on memory or other"
294
- str << " resources."
295
- return str
285
+ str = 'The driver for the device might be corrupted, or the'
286
+ str << ' system may be running low on memory or other'
287
+ str << ' resources.'
288
+ str
296
289
  when 4
297
- str = "The device is not working properly. One of the drivers"
298
- str << " or the registry might be corrupted."
299
- return str
290
+ str = 'The device is not working properly. One of the drivers'
291
+ str << ' or the registry might be corrupted.'
292
+ str
300
293
  when 5
301
- str = "The driver for this device needs a resource that"
302
- str << " Windows cannot manage."
303
- return str
294
+ str = 'The driver for this device needs a resource that'
295
+ str << ' Windows cannot manage.'
296
+ str
304
297
  when 6
305
- str = "The boot configuration for this device conflicts with"
306
- str << " other devices."
307
- return str
298
+ str = 'The boot configuration for this device conflicts with'
299
+ str << ' other devices.'
300
+ str
308
301
  when 7
309
- str = "Cannot filter."
310
- return str
302
+ 'Cannot filter.'
311
303
  when 8
312
- str = "The driver loader for the device is missing."
313
- return str
304
+ 'The driver loader for the device is missing.'
314
305
  when 9
315
- str = "This device is not working properly because the"
316
- str << " controlling firmware is reporting the resources"
317
- str << " for the device incorrectly."
318
- return str
306
+ str = 'This device is not working properly because the'
307
+ str << ' controlling firmware is reporting the resources'
308
+ str << ' for the device incorrectly.'
309
+ str
319
310
  when 10
320
- str = "This device cannot start."
321
- return str
311
+ 'This device cannot start.'
322
312
  when 11
323
- str = "This device failed."
324
- return str
313
+ 'This device failed.'
325
314
  when 12
326
- str = "This device cannot find enough free resources that"
327
- str << " it can use."
328
- return str
315
+ str = 'This device cannot find enough free resources that'
316
+ str << ' it can use.'
317
+ str
329
318
  when 13
330
- str = "Windows cannot verify this device's resources."
331
- return str
319
+ "Windows cannot verify this device's resources."
332
320
  when 14
333
- str = "This device cannot work properly until you restart"
334
- str << " your computer."
335
- return str
321
+ str = 'This device cannot work properly until you restart'
322
+ str << ' your computer.'
323
+ str
336
324
  when 15
337
- str = "This device is not working properly because there is"
338
- str << " probably a re-enumeration problem."
339
- return str
325
+ str = 'This device is not working properly because there is'
326
+ str << ' probably a re-enumeration problem.'
327
+ str
340
328
  when 16
341
- str = "Windows cannot identify all the resources this device "
342
- str << " uses."
343
- return str
329
+ str = 'Windows cannot identify all the resources this device '
330
+ str << ' uses.'
331
+ str
344
332
  when 17
345
- str = "This device is asking for an unknown resource type."
346
- return str
333
+ 'This device is asking for an unknown resource type.'
347
334
  when 18
348
- str = "Reinstall the drivers for this device."
349
- return str
335
+ 'Reinstall the drivers for this device.'
350
336
  when 19
351
- str = "Failure using the VXD loader."
352
- return str
337
+ 'Failure using the VXD loader.'
353
338
  when 20
354
- str = "Your registry might be corrupted."
355
- return str
339
+ 'Your registry might be corrupted.'
356
340
  when 21
357
- str = "System failure: try changing the driver for this device."
358
- str << " If that does not work, see your hardware documentation."
359
- str << " Windows is removing this device."
360
- return str
341
+ str = 'System failure: try changing the driver for this device.'
342
+ str << ' If that does not work, see your hardware documentation.'
343
+ str << ' Windows is removing this device.'
344
+ str
361
345
  when 22
362
- str = "This device is disabled."
363
- return str
346
+ 'This device is disabled.'
364
347
  when 23
365
- str = "System failure: try changing the driver for this device."
348
+ str = 'System failure: try changing the driver for this device.'
366
349
  str << "If that doesn't work, see your hardware documentation."
367
- return str
350
+ str
368
351
  when 24
369
- str = "This device is not present, not working properly, or"
370
- str << " does not have all its drivers installed."
371
- return str
372
- when 25
373
- str = "Windows is still setting up this device."
374
- return str
375
- when 26
376
- str = "Windows is still setting up this device."
377
- return str
352
+ str = 'This device is not present, not working properly, or'
353
+ str << ' does not have all its drivers installed.'
354
+ str
355
+ when 25, 26
356
+ 'Windows is still setting up this device.'
378
357
  when 27
379
- str = "This device does not have valid log configuration."
380
- return str
358
+ 'This device does not have valid log configuration.'
381
359
  when 28
382
- str = "The drivers for this device are not installed."
383
- return str
360
+ 'The drivers for this device are not installed.'
384
361
  when 29
385
- str = "This device is disabled because the firmware of the"
386
- str << " device did not give it the required resources."
387
- return str
362
+ str = 'This device is disabled because the firmware of the'
363
+ str << ' device did not give it the required resources.'
364
+ str
388
365
  when 30
389
- str = "This device is using an Interrupt Request (IRQ)"
390
- str << " resource that another device is using."
391
- return str
366
+ str = 'This device is using an Interrupt Request (IRQ)'
367
+ str << ' resource that another device is using.'
368
+ str
392
369
  when 31
393
- str = "This device is not working properly because Windows"
394
- str << " cannot load the drivers required for this device"
395
- return str
396
- else
397
- return nil
370
+ str = 'This device is not working properly because Windows'
371
+ str << ' cannot load the drivers required for this device'
372
+ str
398
373
  end
399
374
  end
400
375
 
376
+ private_class_method :get_cmec
377
+
401
378
  # Convert an cpu architecture number to a string
402
379
  def self.get_cpu_arch(num)
403
380
  case num
404
381
  when 0
405
- return "x86"
382
+ 'x86'
406
383
  when 1
407
- return "MIPS"
384
+ 'MIPS'
408
385
  when 2
409
- return "Alpha"
386
+ 'Alpha'
410
387
  when 3
411
- return "PowerPC"
388
+ 'PowerPC'
412
389
  when 6
413
- return "IA64"
390
+ 'IA64'
414
391
  when 9
415
- return "x64"
416
- else
417
- return nil
392
+ 'x64'
418
393
  end
419
394
  end
420
395
 
396
+ private_class_method :get_cpu_arch
397
+
421
398
  # convert an Availability number into a string
422
399
  def self.get_availability(num)
423
400
  case num
424
401
  when 1
425
- return "Other"
402
+ 'Other'
426
403
  when 2
427
- return "Unknown"
404
+ 'Unknown'
428
405
  when 3
429
- return "Running"
406
+ 'Running'
430
407
  when 4
431
- return "Warning"
408
+ 'Warning'
432
409
  when 5
433
- return "In Test"
410
+ 'In Test'
434
411
  when 6
435
- return "Not Applicable"
412
+ 'Not Applicable'
436
413
  when 7
437
- return "Power Off"
414
+ 'Power Off'
438
415
  when 8
439
- return "Off Line"
416
+ 'Off Line'
440
417
  when 9
441
- return "Off Duty"
418
+ 'Off Duty'
442
419
  when 10
443
- return "Degraded"
420
+ 'Degraded'
444
421
  when 11
445
- return "Not Installed"
422
+ 'Not Installed'
446
423
  when 12
447
- return "Install Error"
424
+ 'Install Error'
448
425
  when 13
449
- return "Power Save - Unknown"
426
+ 'Power Save - Unknown'
450
427
  when 14
451
- return "Power Save - Low Power Mode"
428
+ 'Power Save - Low Power Mode'
452
429
  when 15
453
- return "Power Save - Standby"
430
+ 'Power Save - Standby'
454
431
  when 16
455
- return "Power Cycle"
432
+ 'Power Cycle'
456
433
  when 17
457
- return "Power Save - Warning"
434
+ 'Power Save - Warning'
458
435
  when 18
459
- return "Paused"
436
+ 'Paused'
460
437
  when 19
461
- return "Not Ready"
438
+ 'Not Ready'
462
439
  when 20
463
- return "Not Configured"
440
+ 'Not Configured'
464
441
  when 21
465
- return "Quiesced"
466
- else
467
- return nil
442
+ 'Quiesced'
468
443
  end
469
444
  end
470
445
 
446
+ private_class_method :get_availability
447
+
471
448
  # convert CpuStatus to a string form. Note that values 5 and 6 are
472
449
  # skipped because they're reserved.
473
450
  def self.get_status(num)
474
451
  case num
475
452
  when 0
476
- return "Unknown"
453
+ 'Unknown'
477
454
  when 1
478
- return "Enabled"
455
+ 'Enabled'
479
456
  when 2
480
- return "Disabled by User via BIOS Setup"
457
+ 'Disabled by User via BIOS Setup'
481
458
  when 3
482
- return "Disabled By BIOS (POST Error)"
459
+ 'Disabled By BIOS (POST Error)'
483
460
  when 4
484
- return "Idle"
461
+ 'Idle'
485
462
  when 7
486
- return "Other"
487
- else
488
- return nil
463
+ 'Other'
489
464
  end
490
465
  end
491
466
 
467
+ private_class_method :get_status
468
+
492
469
  # Convert a family number into the equivalent string
470
+ #
471
+ # NOTE: This could be out of date as new data is added occasionally.
472
+ # If there's a nicer way to do this, please send a PR my way.
473
+ #
493
474
  def self.get_family(num)
494
475
  case num
495
476
  when 1
496
- return "Other"
477
+ 'Other'
497
478
  when 2
498
- return "Unknown"
479
+ 'Unknown'
499
480
  when 3
500
- return "8086"
481
+ '8086'
501
482
  when 4
502
- return "80286"
483
+ '80286'
503
484
  when 5
504
- return "80386"
485
+ '80386'
505
486
  when 6
506
- return "80486"
487
+ '80486'
507
488
  when 7
508
- return "8087"
489
+ '8087'
509
490
  when 8
510
- return "80287"
491
+ '80287'
511
492
  when 9
512
- return "80387"
493
+ '80387'
513
494
  when 10
514
- return "80487"
495
+ '80487'
515
496
  when 11
516
- return "Pentium?"
497
+ 'Pentium'
517
498
  when 12
518
- return "Pentium?"
499
+ 'Pentium Pro'
519
500
  when 13
520
- return "Pentium?"
501
+ 'Pentium II'
521
502
  when 14
522
- return "Pentium?"
503
+ 'Pentium with MMX'
523
504
  when 15
524
- return "Celeron?"
505
+ 'Celeron'
525
506
  when 16
526
- return "Pentium?"
507
+ 'Pentium II Xeon'
527
508
  when 17
528
- return "Pentium?"
509
+ 'Pentium III'
529
510
  when 18
530
- return "M1"
511
+ 'M1'
531
512
  when 19
532
- return "M2"
513
+ 'M2'
533
514
  when 24
534
- return "K5"
515
+ 'K5'
535
516
  when 25
536
- return "K6"
517
+ 'K6'
537
518
  when 26
538
- return "K6-2"
519
+ 'K6-2'
539
520
  when 27
540
- return "K6-3"
521
+ 'K6-3'
541
522
  when 28
542
- return "AMD"
523
+ 'AMD Athlon'
543
524
  when 29
544
- return "AMD?"
525
+ 'AMD Duron'
545
526
  when 30
546
- return "AMD2900"
527
+ 'AMD2900'
547
528
  when 31
548
- return "K6-2+"
529
+ 'K6-2+'
549
530
  when 32
550
- return "Power"
531
+ 'Power PC'
551
532
  when 33
552
- return "Power"
533
+ 'Power 601'
553
534
  when 34
554
- return "Power"
535
+ 'Power 603'
555
536
  when 35
556
- return "Power"
537
+ 'Power 603+'
557
538
  when 36
558
- return "Power"
539
+ 'Power 604'
559
540
  when 37
560
- return "Power"
541
+ 'Power 620'
561
542
  when 38
562
- return "Power"
543
+ 'Power X704'
563
544
  when 39
564
- return "Power"
545
+ 'Power 750'
565
546
  when 48
566
- return "Alpha"
547
+ 'Alpha'
567
548
  when 49
568
- return "Alpha"
549
+ 'Alpha 21064'
569
550
  when 50
570
- return "Alpha"
551
+ 'Alpha 21066'
571
552
  when 51
572
- return "Alpha"
553
+ 'Alpha 21164'
573
554
  when 52
574
- return "Alpha"
555
+ 'Alpha 21164PC'
575
556
  when 53
576
- return "Alpha"
557
+ 'Alpha 21164a'
577
558
  when 54
578
- return "Alpha"
559
+ 'Alpha 21264'
579
560
  when 55
580
- return "Alpha"
561
+ 'Alpha 21364'
581
562
  when 64
582
- return "MIPS"
563
+ 'MIPS'
583
564
  when 65
584
- return "MIPS"
565
+ 'MIPS R4000'
585
566
  when 66
586
- return "MIPS"
567
+ 'MIPS R4200'
587
568
  when 67
588
- return "MIPS"
569
+ 'MIPS R4400'
589
570
  when 68
590
- return "MIPS"
571
+ 'MIPS R4600'
591
572
  when 69
592
- return "MIPS"
573
+ 'MIPS R10000'
593
574
  when 80
594
- return "SPARC"
575
+ 'SPARC'
595
576
  when 81
596
- return "SuperSPARC"
577
+ 'SuperSPARC'
597
578
  when 82
598
- return "microSPARC"
579
+ 'microSPARC II'
599
580
  when 83
600
- return "microSPARC"
581
+ 'microSPARC IIep'
601
582
  when 84
602
- return "UltraSPARC"
583
+ 'UltraSPARC'
603
584
  when 85
604
- return "UltraSPARC"
585
+ 'UltraSPARC II'
605
586
  when 86
606
- return "UltraSPARC"
587
+ 'UltraSPARC IIi'
607
588
  when 87
608
- return "UltraSPARC"
589
+ 'UltraSPARC III'
609
590
  when 88
610
- return "UltraSPARC"
591
+ 'UltraSPARC IIIi'
611
592
  when 96
612
- return "68040"
593
+ '68040'
613
594
  when 97
614
- return "68xxx"
595
+ '68xxx'
615
596
  when 98
616
- return "68000"
597
+ '68000'
617
598
  when 99
618
- return "68010"
599
+ '68010'
619
600
  when 100
620
- return "68020"
601
+ '68020'
621
602
  when 101
622
- return "68030"
603
+ '68030'
623
604
  when 112
624
- return "Hobbit"
605
+ 'Hobbit'
625
606
  when 120
626
- return "Crusoe?"
607
+ 'Crusoe TM5000'
627
608
  when 121
628
- return "Crusoe?"
609
+ 'Crusoe TM3000'
629
610
  when 128
630
- return "Weitek"
611
+ 'Weitek'
631
612
  when 130
632
- return "Itanium?"
613
+ 'Itanium'
614
+ when 131
615
+ 'AMD Athlon 64'
616
+ when 132
617
+ 'AMD Opteron'
618
+ when 133
619
+ 'AMD Sempron'
620
+ when 134
621
+ 'AMD Turion 64 Mobile'
622
+ when 135
623
+ 'AMD Opteron Dual-Core'
624
+ when 136
625
+ 'AMD Athlon 64 X2 Dual-Core'
626
+ when 137
627
+ 'AMD Turion 64 X2 Mobile'
628
+ when 138
629
+ 'AMD Opteron Quad-Core'
630
+ when 139
631
+ 'AMD Opteron Third Generation'
632
+ when 140
633
+ 'AMD Phenom FX Quad-Core'
634
+ when 141
635
+ 'AMD Phenom X4 Quad-Core'
636
+ when 142
637
+ 'AMD Phenom X2 Dual-Core'
638
+ when 143
639
+ 'AMD Athlon X2 Dual-Core'
633
640
  when 144
634
- return "PA-RISC"
641
+ 'PA-RISC'
635
642
  when 145
636
- return "PA-RISC"
643
+ 'PA-RISC 8500'
637
644
  when 146
638
- return "PA-RISC"
645
+ 'PA-RISC 8000'
639
646
  when 147
640
- return "PA-RISC"
647
+ 'PA-RISC 7300LC'
641
648
  when 148
642
- return "PA-RISC"
649
+ 'PA-RISC 7200'
643
650
  when 149
644
- return "PA-RISC"
651
+ 'PA-RISC 7100LC'
645
652
  when 150
646
- return "PA-RISC"
653
+ 'PA-RISC 7100'
647
654
  when 160
648
- return "V30"
655
+ 'V30'
656
+ when 161
657
+ 'Intel Xeon 3200 Quad-Core'
658
+ when 162
659
+ 'Intel Xeon 3000 Dual-Core'
660
+ when 163
661
+ 'Intel Xeon 5300 Quad-Core'
662
+ when 164
663
+ 'Intel Xeon 5100 Dual-Core'
664
+ when 165
665
+ 'Intel Xeon 5000 Dual-Core'
666
+ when 166
667
+ 'Intel Xeon LV Dual-Core'
668
+ when 167
669
+ 'Intel Xeon ULV Dual-Core'
670
+ when 168
671
+ 'Intel Xeon 7100 Dual-Core'
672
+ when 169
673
+ 'Intel Xeon 5400 Quad-Core'
674
+ when 170
675
+ 'Intel Xeon Quad-Core'
676
+ when 171
677
+ 'Intel Xeon 5200 Dual-Core'
678
+ when 172
679
+ 'Intel Xeon 7200 Dual-Core'
680
+ when 173
681
+ 'Intel Xeon 7300 Quad-Core'
682
+ when 174
683
+ 'Intel Xeon 7400 Quad-Core'
684
+ when 175
685
+ 'Intel Xeon 7400 Multi-Core'
649
686
  when 176
650
- return "Pentium?"
687
+ 'Pentium III Xeon'
651
688
  when 177
652
- return "Pentium?"
689
+ 'Pentium III with SpeedStep'
653
690
  when 178
654
- return "Pentium?"
691
+ 'Pentium 4'
655
692
  when 179
656
- return "Intel?"
693
+ 'Intel Xeon'
657
694
  when 180
658
- return "AS400"
695
+ 'AS400'
659
696
  when 181
660
- return "Intel?"
697
+ 'Intel Xeon MP'
661
698
  when 182
662
- return "AMD"
699
+ 'AMD Athlon XP'
663
700
  when 183
664
- return "AMD"
701
+ 'AMD Athlon MP'
665
702
  when 184
666
- return "Intel?"
703
+ 'Intel Itanium 2'
667
704
  when 185
668
- return "AMD"
705
+ 'Intel Pentium M'
706
+ when 186
707
+ 'Intel Celeron D'
708
+ when 187
709
+ 'Intel Pentium D'
710
+ when 188
711
+ 'Intel Pentium Extreme Edition'
712
+ when 189
713
+ 'Intel Core Solo'
669
714
  when 190
670
- return "K7"
715
+ 'K7'
716
+ when 191
717
+ 'Intel Core2 Duo'
718
+ when 192
719
+ 'Intel Core2 Solo'
720
+ when 193
721
+ 'Intel Core2 Extreme'
722
+ when 194
723
+ 'Intel Core2 Quad'
724
+ when 195
725
+ 'Intel Core2 Extreme Mobile'
726
+ when 196
727
+ 'Intel Core2 Duo Mobile'
728
+ when 197
729
+ 'Intel Core2 Solo Mobile'
730
+ when 198
731
+ 'Intel Core i7 Mobile'
732
+ when 199
733
+ 'Intel Celeron Dual-Core'
671
734
  when 200
672
- return "IBM390"
735
+ 'zSeries S/390'
673
736
  when 201
674
- return "G4"
737
+ 'ESA/390 G4'
675
738
  when 202
676
- return "G5"
739
+ 'ESA/390 G5'
740
+ when 203
741
+ 'ESA/390 G6'
742
+ when 204
743
+ 'z/Architectur'
744
+ when 205
745
+ 'Intel Core i5'
746
+ when 206
747
+ 'Intel Core i3'
748
+ when 210
749
+ 'VIA C7-M'
750
+ when 211
751
+ 'VIA C7-D'
752
+ when 212
753
+ 'VIA C7'
754
+ when 213
755
+ 'VIA Eden'
756
+ when 214
757
+ 'Intel Xeon Multi-Core'
758
+ when 215
759
+ 'Intel Xeon 3xxx Dual-Core'
760
+ when 216
761
+ 'Intel Xeon 3xxx Quad-Core'
762
+ when 217
763
+ 'VIA Nano'
764
+ when 218
765
+ 'Intel Xeon 5xxx Dual-Core'
766
+ when 219
767
+ 'Intel Xeon 5xxx Quad-Core'
768
+ when 221
769
+ 'Intel Xeon 7xxx Dual-Core'
770
+ when 222
771
+ 'Intel Xeon 7xxx Quad-Core'
772
+ when 223
773
+ 'Intel Xeon 7xxx Multi-Core'
774
+ when 224
775
+ 'Intel Xeon 3400 Multi-Core'
776
+ when 230
777
+ 'AMD Opteron Embedded Quad-Core'
778
+ when 231
779
+ 'AMD Phenom Triple-Core'
780
+ when 232
781
+ 'AMD Turion Ultra Dual-Core Mobile'
782
+ when 233
783
+ 'AMD Turion Dual-Core Mobile'
784
+ when 234
785
+ 'AMD Athlon Dual-Core'
786
+ when 235
787
+ 'AMD Sempron SI'
788
+ when 236
789
+ 'AMD Phenom II'
790
+ when 237
791
+ 'AMD Athlon II'
792
+ when 238
793
+ 'AMD Opteron Six-Core'
794
+ when 239
795
+ 'AMD Sempron M'
677
796
  when 250
678
- return "i860"
797
+ 'i860'
679
798
  when 251
680
- return "i960"
799
+ 'i960'
681
800
  when 260
682
- return "SH-3"
801
+ 'SH-3'
683
802
  when 261
684
- return "SH-4"
803
+ 'SH-4'
685
804
  when 280
686
- return "ARM"
805
+ 'ARM'
687
806
  when 281
688
- return "StrongARM"
807
+ 'StrongARM'
689
808
  when 300
690
- return "6x86"
809
+ '6x86'
691
810
  when 301
692
- return "MediaGX"
811
+ 'MediaGX'
693
812
  when 302
694
- return "MII"
813
+ 'MII'
695
814
  when 320
696
- return "WinChip"
815
+ 'WinChip'
697
816
  when 350
698
- return "DSP"
817
+ 'DSP'
699
818
  when 500
700
- return "Video"
701
- else
702
- return nil
819
+ 'Video'
703
820
  end
704
821
  end
705
822
 
823
+ private_class_method :get_family
824
+
706
825
  # Convert power management capabilities number to its equivalent string
707
826
  def self.get_pmc(num)
708
827
  case num
709
828
  when 0
710
- return "Unknown"
829
+ 'Unknown'
711
830
  when 1
712
- return "Not Supported"
831
+ 'Not Supported'
713
832
  when 2
714
- return "Disabled"
833
+ 'Disabled'
715
834
  when 3
716
- return "Enabled"
835
+ 'Enabled'
717
836
  when 4
718
- return "Power Saving Modes Entered Automatically"
837
+ 'Power Saving Modes Entered Automatically'
719
838
  when 5
720
- return "Power State Settable"
839
+ 'Power State Settable'
721
840
  when 6
722
- return "Power Cycling Supported"
841
+ 'Power Cycling Supported'
723
842
  when 7
724
- return "Timed Power On Supported"
725
- else
726
- return nil
843
+ 'Timed Power On Supported'
727
844
  end
728
845
  end
729
846
 
847
+ private_class_method :get_pmc
848
+
730
849
  # Convert a processor type into its equivalent string
731
850
  def self.get_processor_type(num)
732
851
  case num
733
852
  when 1
734
- return "Other"
853
+ 'Other'
735
854
  when 2
736
- return "Unknown"
855
+ 'Unknown'
737
856
  when 3
738
- return "Central Processor"
857
+ 'Central Processor'
739
858
  when 4
740
- return "Math Processor"
859
+ 'Math Processor'
741
860
  when 5
742
- return "DSP Processor"
861
+ 'DSP Processor'
743
862
  when 6
744
- return "Video Processor"
745
- else
746
- return nil
863
+ 'Video Processor'
747
864
  end
748
865
  end
749
866
 
867
+ private_class_method :get_processor_type
868
+
750
869
  # Convert an upgrade method into its equivalent string
751
870
  def self.get_upgrade_method(num)
752
871
  case num
753
872
  when 1
754
- return "Other"
873
+ 'Other'
755
874
  when 2
756
- return "Unknown"
875
+ 'Unknown'
757
876
  when 3
758
- return "Daughter Board"
877
+ 'Daughter Board'
759
878
  when 4
760
- return "ZIF Socket"
879
+ 'ZIF Socket'
761
880
  when 5
762
- return "Replacement/Piggy Back"
881
+ 'Replacement/Piggy Back'
763
882
  when 6
764
- return "None"
883
+ 'None'
765
884
  when 7
766
- return "LIF Socket"
885
+ 'LIF Socket'
767
886
  when 8
768
- return "Slot 1"
887
+ 'Slot 1'
769
888
  when 9
770
- return "Slot 2"
889
+ 'Slot 2'
771
890
  when 10
772
- return "370 Pin Socket"
891
+ '370 Pin Socket'
773
892
  when 11
774
- return "Slot A"
893
+ 'Slot A'
775
894
  when 12
776
- return "Slot M"
777
- else
778
- return nil
895
+ 'Slot M'
779
896
  end
780
897
  end
781
898
 
899
+ private_class_method :get_upgrade_method
900
+
782
901
  # Convert return values to voltage cap values (floats)
783
902
  def self.get_voltage_caps(num)
784
903
  case num
785
904
  when 1
786
- return 5.0
905
+ 5.0
787
906
  when 2
788
- return 3.3
907
+ 3.3
789
908
  when 4
790
- return 2.9
791
- else
792
- return nil
909
+ 2.9
793
910
  end
794
911
  end
912
+
913
+ private_class_method :get_voltage_caps
795
914
  end
796
915
  end