Skip to content
Ruby Gem to get total memory size in the system
Ruby
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
test
.0pdd.yml
.gitignore
.pdd
.rubocop.yml
.rultor.yml
.travis.yml
Gemfile
README.md
Rakefile
logo.svg
total.gemspec

README.md

Managed by Zerocracy EO principles respected here DevOps By Rultor.com We recommend RubyMine

Build Status Gem Version Maintainability Yard Docs

License Test Coverage Hits-of-Code

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, Total::CantDetect exception 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.

That's it.

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.

You can’t perform that action at this time.