返回顶部

收藏

Easy OS Detection with RUBY_PLATFORM

更多
if RUBY_PLATFORM =~ /win32/
  puts 'We're in Windows!'
elsif RUBY_PLATFORM =~ /linux/
  puts 'We're in Linux!'
elsif RUBY_PLATFORM =~ /darwin/
  puts 'We're in Mac OS X!'
elsif RUBY_PLATFORM =~ /freebsd/
  puts 'We're in FreeBSD!'
else
  puts 'We're running under an unknown operating system.'
end

标签:Ruby,基础

收藏

0人收藏

支持

0

反对

0

发表评论