Total is a Ruby gem to detect the total amount of memory in the system.
First, install it:
$ gem install total
Then, use it like this:
require 'total' puts Total::Mem.new.bytes
The following platforms are supported:
If the platform is not recognized or is not supported,
will be raised. You should catch it and proceed accordingly, for example:
def total_mb Total::Mem.new.bytes / (1024 * 1024) rescue Total::CantDetect 512 end
This code will return the actual memory size in Mb, if it can be detected, or 512 otherwise.
How to contribute
Read these guidelines. Make sure you build is green before you contribute your pull request. You will need to have Ruby 2.3+ and Bundler installed. Then:
$ bundle update $ bundle exec rake
If it's clean and you don't see any error messages, submit your pull request.