I am well aware that you can check your current OS using the os
gem. But what I have not found is how to get the specific OS version. For example, if I am running the Ruby project on Windows 8.1, I want Windows 8.1 to be printed instead of just Windows.
Asked
Active
Viewed 1,162 times
2
-
http://stackoverflow.com/questions/170956/how-can-i-find-which-operating-system-my-ruby-program-is-running-on – Benjamin Sep 30 '16 at 11:52
-
or: http://stackoverflow.com/a/13586108/954421 – Benjamin Sep 30 '16 at 11:53
-
I'm afraid you don't understand my question. The links you provided don't provide the version number – Sep 30 '16 at 12:24
2 Answers
0
I've take a look on the specs of OS gem and unfortunately I couldn't find such method or attribute for that.
One alternative: you can execute your own system calls (via cocaine gem):
- on linux you can find through
lsb-release
or other methods - on OSX:
sw_vers -productVersion
- On Windows
ver
through command.
Perhaps you can try to add it on the gem itself create a new PR?

AndreDurao
- 5,600
- 7
- 41
- 61
0
Try using the gem sys-uname : https://rubygems.org/gems/sys-uname
require 'sys/uname'
include Sys
class Test
puts Uname.uname
end
This is the output:
....., build_number="7601", build_type="Multiprocessor Free", caption="Microsoft Windows 7 Professional ", code_set="1252", country_code="1", creation_class_name="Win32_OperatingSystem", cscreation_class_name="Win32_ComputerSystem", csd_version="Service Pack 1", ...
plus other details

Sid
- 408
- 4
- 7