Module: YandexSpeechApi::Helpers
- Defined in:
- lib/yandex_speech/helpers.rb
Class Method Summary collapse
-
.find_executable(cmd) ⇒ Pathname, NilClass
Searches pathname for executable
cmd
. -
.recognize_operation_system ⇒ Symbol
From what OS we launched?.
Class Method Details
.find_executable(cmd) ⇒ Pathname, NilClass
Searches pathname for executable cmd
.
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/yandex_speech/helpers.rb', line 38 def self.find_executable(cmd) possible_extensions = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| possible_extensions.each do |extension| exe = Pathname.new(File.join(path, "#{cmd}#{extension}")) return exe if exe.executable? && exe.file? end end return nil # search unsuccessful end |
.recognize_operation_system ⇒ Symbol
From what OS we launched?
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/yandex_speech/helpers.rb', line 18 def self.recognize_operation_system case RbConfig::CONFIG['host_os'] when /mswin|msys|mingw|cygwin|bccwin|wince|emc/ :windows when /darwin|mac os/ :mac_os when /linux/ :linux else :unknown end end |