Ruby怎樣獲取作業系統的Name

2021-08-31 19:28:44 字數 478 閱讀 1246

在看selenium源**的時候, 發現了獲取作業系統的更好方法

def os

@os ||= (

host_os = rbconfig::config['host_os']

case host_os

when /mswin|msys|mingw|cygwin|bccwin|wince|emc/

:windows

when /darwin|mac os/

:macosx

when /linux/

:linux

when /solaris|bsd/

:unix

else

raise error::webdrivererror, "unknown os: #"

end)

end

之前用的方法是假定是windows, 如果不是的話根據異常處理來判斷是否是mac, 很麻煩

前端獲取作業系統 作業系統版本

在做埋點的過程中,遇到要上傳作業系統和作業系統版本的需求,如下 通過n igator.useragent獲取首先將作業系統確定為如下對映 all os 獲取當前作業系統 獲取當前作業系統 export const getos if useragent.includes mac else if use...

獲取作業系統型別

新增自定義型別,用作判斷系統型別,type tosversion osunknown,os95,os98,osme,osnt3,osnt4,os2k,osxp,os2k3 新增自定義函式過程 function getos tosversion 獲得系統型別,用來取得托盤控制代碼 varos tosv...

獲取作業系統資訊

osversioninfo osvi zeromemory osvi,sizeof osversioninfo osvi.dwosversioninfosize sizeof osversioninfo getversionex osvi 通過osvi這個結構體資訊來獲取作業系統資訊 typedef...