Class: Total::Linux

Inherits:
Object
  • Object
show all
Defined in:
lib/total/linux.rb

Overview

Linux specifics.

Instance Method Summary collapse

Instance Method Details

#memoryObject

Get the total in bytes

Raises:



34
35
36
37
38
39
40
# File 'lib/total/linux.rb', line 34

def memory
  raise CantDetect unless File.exist?('/proc/meminfo')
  IO.readlines('/proc/meminfo').each do |t|
    return t.split(/ +/)[1].to_i * 1024 if t.start_with?('MemTotal:')
  end
  raise CantDetect, 'Can\'t detect memory size at /proc/meminfo'
end