在Ruby中检测操作系统 [英] Detecting Operating Systems in Ruby

查看:103
本文介绍了在Ruby中检测操作系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法检测红宝石中的操作系统?我正在开发一个Sketchup工具,该工具需要检测Mac与Windows.

Is there a way to detect the operating system in ruby? I am working on developing a sketchup tool that will need to detect Mac vs. Windows.

推荐答案

您可以使用os gem:

gem install os

然后

require 'os'
OS.linux?   #=> true or false
OS.windows? #=> true or false
OS.java?    #=> true or false
OS.bsd?     #=> true or false
OS.mac?     #=> true or false
# and so on.

请参阅: https://github.com/rdp/os

这篇关于在Ruby中检测操作系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆