Class: DeepTest::CpuInfo
- Inherits:
-
Object
- Object
- DeepTest::CpuInfo
- Defined in:
- lib/deep_test/cpu_info.rb
Instance Attribute Summary collapse
-
#platform ⇒ Object
Returns the value of attribute platform.
Instance Method Summary collapse
- #count ⇒ Object
-
#initialize(platform = RUBY_PLATFORM) ⇒ CpuInfo
constructor
A new instance of CpuInfo.
Constructor Details
#initialize(platform = RUBY_PLATFORM) ⇒ CpuInfo
Returns a new instance of CpuInfo.
5 6 7 |
# File 'lib/deep_test/cpu_info.rb', line 5 def initialize(platform = RUBY_PLATFORM) @platform = platform end |
Instance Attribute Details
#platform ⇒ Object
Returns the value of attribute platform.
3 4 5 |
# File 'lib/deep_test/cpu_info.rb', line 3 def platform @platform end |
Instance Method Details
#count ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/deep_test/cpu_info.rb', line 9 def count case platform when /darwin/ output = `sysctl -n hw.ncpu` output.strip.to_i when /linux/ File.readlines("/proc/cpuinfo").inject(0) do |count, line| next count + 1 if line =~ /processor\s*:\s*\d+/ count end end end |