Eine kleine Funktion, um die Plattform zu bestimmen, auf der Ruby läuft:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
def platform
$RUBY_PLATFORM ||=
case RUBY_PLATFORM.downcase
when /linux|bsd|solaris|hpux|darwin/
:unix
when /mswin32|mingw32|bccwin32/
:windows
when /cygwin/
:cygwin
when /java/
:java
else
:other
end
end
p platform |
- 09.09.06: Darwin gibt's nun auch mit i686
- 14.05.05: Cygwin extra, weil es weder Windows noch Unix klar zuzuordnen ist. Anmerkung von raistlin77
- 13.05.05: Vorgeschlagen im Forum von Winfried.
- 13.05.05: Erweitert (caching in $RUBY_PLATFORM, vereinfachte Regexps) von Murphy.