Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby How to determine execution environment

I need to determine what environment my ruby script is running in so I can remove files and clean up directories after execution.

I tried using ENV['os'] but I am using cygwin and it gave me Windows_NT, Does anyone know a way to find the current environment?

Thanks

like image 290
Hunter McMillen Avatar asked Jun 29 '11 15:06

Hunter McMillen


1 Answers

The current environment is provided by the global constant RUBY_PLATFORM

ruby invoked at the cygwin bash shell (/usr/bin/ruby):

puts RUBY_PLATFORM
i386-cygwin

ruby invoked at the command prompt (c:\Ruby193\bin\ruby.exe):

puts RUBY_PLATFORM
i386-mingw32

puts ENV['OS'] for both of the above environment returns: Windows_NT

like image 144
nick1176 Avatar answered Sep 22 '22 00:09

nick1176