Method: LinuxStat::OS.version

Defined in:
lib/linux_stat/os.rb

.versionObject Also known as: distrib_version

Gives you the version of the OS you are using.

On ArchLinux for example:

LinuxStat::OS.version

=> "rolling"

On Ubuntu 20.04:

LinuxStat::OS.version

=> "20.04"

On CentOS 26:

LinuxStat::OS.version

=> "26"

The return type is String. But if the information isn’t available, it will return an empty frozen String.



88
89
90
91
92
93
94
95
96
97
98
# File 'lib/linux_stat/os.rb', line 88

def version
	@@distrib_version ||= if os_release.key?(:VERSION_ID)
		os_release[:VERSION_ID]
	elsif lsb_release.key?(:DISTRIB_RELEASE)
		lsb_release[:DISTRIB_RELEASE]
	elsif os_release.key?(:VERSION)
		os_release[:VERSION]
	else
		''.freeze
	end
end