Program to find ruby version

We can easily find the version of ruby during program execution. There are few constant variable available which are provide this information.

# ruby -v
print("#{RUBY_DESCRIPTION}")

Output

ruby 3.0.3p157 (2021-11-24 revision 3fb7d2cadc) [x86_64-linux-musl]

This result contain various information. We can fetch this information manually.

# Target ENGINE
print("Target : ",RUBY_ENGINE,"\n") 

# Ruby version
print("Version : ",RUBY_VERSION,"\n") 

# Patchlevel version
print("Patchlevel : ",RUBY_PATCHLEVEL,"\n") 

# Target PLATFORM 
print("Platform : ",RUBY_PLATFORM,"\n") 

# RELEASE DATE 
print("Release Date : ",RUBY_RELEASE_DATE,"\n") 


# ENGINE VERSION  
print("Engine Version : ",RUBY_ENGINE_VERSION,"\n")

# RUBY REVISION
print("Revision  : ",RUBY_REVISION,"\n")


# RUBY COPYRIGHT
print("COPYRIGHT  : ",RUBY_COPYRIGHT,"\n")

Output

Target : ruby
Version : 3.0.3
Patchlevel : 157
Platform : x86_64-linux-musl
Release Date : 2021-11-24
Engine Version : 3.0.3
Revision  : 3fb7d2cadc18472ec107b14234933b017a33c14d
COPYRIGHT  : ruby - Copyright (C) 1993-2021 Yukihiro Matsumoto



Comment

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

New Comment







© 2022, kalkicode.com, All rights reserved