Class: Vli::Util::Platform
- Inherits:
-
Object
- Object
- Vli::Util::Platform
- Defined in:
- lib/vli/util/platform.rb
Overview
This class just contains some platform checking code.
Class Method Summary collapse
-
.bit32? ⇒ Boolean
Returns boolean noting whether this is a 32-bit CPU.
-
.bit64? ⇒ Boolean
Returns boolean noting whether this is a 64-bit CPU.
- .leopard? ⇒ Boolean
- .platform ⇒ Object
- .tar_file_options ⇒ Object
-
.terminal_supports_colors? ⇒ Boolean
Returns a boolean noting whether the terminal supports color.
- .tiger? ⇒ Boolean
- .windows? ⇒ Boolean
Class Method Details
.bit32? ⇒ Boolean
Returns boolean noting whether this is a 32-bit CPU. This can easily throw false positives since it relies on #bit64?.
43 44 45 |
# File 'lib/vli/util/platform.rb', line 43 def bit32? !bit64? end |
.bit64? ⇒ Boolean
Returns boolean noting whether this is a 64-bit CPU. This is not 100% accurate and there could easily be false negatives.
35 36 37 |
# File 'lib/vli/util/platform.rb', line 35 def bit64? ["x86_64", "amd64"].include?(RbConfig::CONFIG["host_cpu"]) end |
.leopard? ⇒ Boolean
13 14 15 |
# File 'lib/vli/util/platform.rb', line 13 def leopard? platform.include?("darwin9") end |
.platform ⇒ Object
62 63 64 |
# File 'lib/vli/util/platform.rb', line 62 def platform RbConfig::CONFIG["host_os"].downcase end |
.tar_file_options ⇒ Object
57 58 59 60 |
# File 'lib/vli/util/platform.rb', line 57 def # create, write only, fail if the file exists, binary if windows File::WRONLY | File::EXCL | File::CREAT | (windows? ? File::BINARY : 0) end |
.terminal_supports_colors? ⇒ Boolean
Returns a boolean noting whether the terminal supports color. output.
49 50 51 52 53 54 55 |
# File 'lib/vli/util/platform.rb', line 49 def terminal_supports_colors? if windows? return ENV.has_key?("ANSICON") end true end |
.tiger? ⇒ Boolean
9 10 11 |
# File 'lib/vli/util/platform.rb', line 9 def tiger? platform.include?("darwin8") end |
.windows? ⇒ Boolean
23 24 25 26 27 28 29 |
# File 'lib/vli/util/platform.rb', line 23 def windows? %W[mingw mswin].each do |text| return true if platform.include?(text) end false end |