To get the system release information in Ruby, you can use the RbConfig::CONFIG
hash to access the host_os
key which contains the operating system name and version. You can then use a regular expression to extract the release information as follows:
main.rb433 chars18 lines
This code snippet uses a case
statement to determine the operating system and execute the appropriate command to obtain the release information. For Linux, it runs the lsb_release
command and extracts the Release
information. For macOS, it runs the sw_vers
command and extracts the productVersion
information. For Windows, the ver
command is used.
gistlibby LogSnag