djberg96/sys-filesystem: A Ruby library for getting filesystem information
Uses FFI and works all relevant operating systems.
If you'd try to do it yourself, you'd have to use FFI which is a bit awkward (see the gem's code), or call commands like df -B1
and search the strings for your relevant data.
That gem takes the pain away and works nicely.