Quantcast
Channel: What's the best-practice way to find out the platform ruby is running on? - Stack Overflow
Viewing all articles
Browse latest Browse all 3

What's the best-practice way to find out the platform ruby is running on?

$
0
0

I am using colored gem for coloured printing in the terminal and ruby logger. I need to run this code on linux and on windows.

On windows, I must first require 'win32console' or else coloured printing doesn't work (I just see ANSI escape characters instead). But if I require win32console on linux it breaks, obviously.

What's the usual way to handle a situation like this in ruby? I noticed the RUBY_PLATFORM variable, but on a windows VM I tried it was "i386-mingw32" or something strange. Using that plus a conditional seems like a pretty flakey way to go about what I need, so I was hoping this problem has a better solution.


Viewing all articles
Browse latest Browse all 3

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>