class Total::Linux

Linux specifics.

Public Instance Methods

memory() click to toggle source

Get the total in bytes

# 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