Class: Platform
Overview
Helper functions for determining platform Usage:
Platform.short_name => osx/windows/linux, depending on your current platform
Platform.new("mswin").short_name => windows, since we are creating an instance.
Class Method Summary collapse
- .linux ⇒ Object
- .linux? ⇒ Boolean
- .mac ⇒ Object
- .mac? ⇒ Boolean
- .preferred_archive ⇒ Object
- .short_name ⇒ Object
- .supported ⇒ Object
- .windows ⇒ Object
- .windows? ⇒ Boolean
Instance Method Summary collapse
-
#initialize(platform = PLATFORM) ⇒ Platform
constructor
A new instance of Platform.
- #linux? ⇒ Boolean
- #mac? ⇒ Boolean
- #short_name ⇒ Object
- #windows? ⇒ Boolean
Constructor Details
#initialize(platform = PLATFORM) ⇒ Platform
Returns a new instance of Platform.
55 56 57 |
# File 'lib/pmsrb/platform.rb', line 55 def initialize(platform = PLATFORM) @platform = platform end |
Class Method Details
.linux ⇒ Object
15 16 17 |
# File 'lib/pmsrb/platform.rb', line 15 def self.linux yield if(linux?) end |
.linux? ⇒ Boolean
27 28 29 |
# File 'lib/pmsrb/platform.rb', line 27 def self.linux? PLATFORM =~ /linux/ end |
.mac ⇒ Object
7 8 9 |
# File 'lib/pmsrb/platform.rb', line 7 def self.mac yield if(mac?) end |
.mac? ⇒ Boolean
19 20 21 |
# File 'lib/pmsrb/platform.rb', line 19 def self.mac? PLATFORM =~ /darwin/ end |
.preferred_archive ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/pmsrb/platform.rb', line 43 def self.preferred_archive if(windows?) "zip" else "tgz" end end |
.short_name ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/pmsrb/platform.rb', line 31 def self.short_name if(mac?) "osx" elsif(windows?) "windows" elsif(linux?) "linux" else "unknown" end end |
.supported ⇒ Object
51 52 53 |
# File 'lib/pmsrb/platform.rb', line 51 def self.supported %w(darwin mswin linux).collect {|x| Platform.new(x)} end |
.windows ⇒ Object
11 12 13 |
# File 'lib/pmsrb/platform.rb', line 11 def self.windows yield if(windows?) end |
.windows? ⇒ Boolean
23 24 25 |
# File 'lib/pmsrb/platform.rb', line 23 def self.windows? PLATFORM =~ /mswin/ end |
Instance Method Details
#linux? ⇒ Boolean
67 68 69 |
# File 'lib/pmsrb/platform.rb', line 67 def linux? @platform =~ /linux/ end |
#mac? ⇒ Boolean
59 60 61 |
# File 'lib/pmsrb/platform.rb', line 59 def mac? @platform =~ /darwin/ end |
#short_name ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/pmsrb/platform.rb', line 71 def short_name if(mac?) "osx" elsif(windows?) "windows" elsif(linux?) "linux" else "unknown" end end |
#windows? ⇒ Boolean
63 64 65 |
# File 'lib/pmsrb/platform.rb', line 63 def windows? @platform =~ /mswin/ end |