Module: CSVPP::OS
- Defined in:
- lib/csvpp/os.rb
Overview
Provides utility functions for determining OS and OS-specific system calls.
Class Method Summary collapse
- .linux? ⇒ Boolean
- .mac? ⇒ Boolean
- .open(str, open_cmd: self.open_cmd) ⇒ Object
- .open_cmd ⇒ Object
- .pager ⇒ Object
- .ruby_platform ⇒ Object
- .unix? ⇒ Boolean
- .windows? ⇒ Boolean
Class Method Details
.linux? ⇒ Boolean
21 22 23 |
# File 'lib/csvpp/os.rb', line 21 def linux? unix? && !mac? end |
.mac? ⇒ Boolean
17 18 19 |
# File 'lib/csvpp/os.rb', line 17 def mac? !!(/darwin/ =~ ruby_platform) end |
.open(str, open_cmd: self.open_cmd) ⇒ Object
25 26 27 |
# File 'lib/csvpp/os.rb', line 25 def open(str, open_cmd: self.open_cmd) system "#{open_cmd} #{str}" end |
.open_cmd ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/csvpp/os.rb', line 29 def open_cmd if mac? 'open' elsif linux? 'xdg-open' elsif windows? 'START ""' else raise 'Unsupported OS' end end |
.pager ⇒ Object
41 42 43 44 |
# File 'lib/csvpp/os.rb', line 41 def pager return nil if windows? ENV['PAGER'] || 'less' end |
.ruby_platform ⇒ Object
46 47 48 |
# File 'lib/csvpp/os.rb', line 46 def ruby_platform RUBY_PLATFORM end |
.unix? ⇒ Boolean
13 14 15 |
# File 'lib/csvpp/os.rb', line 13 def unix? !windows? end |
.windows? ⇒ Boolean
9 10 11 |
# File 'lib/csvpp/os.rb', line 9 def windows? !!(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ ruby_platform) end |