Module: Panoptimon::Util

Defined in:
lib/panoptimon/util.rb

Constant Summary collapse

VERSION =
'0.0.1'

Class Method Summary collapse

Class Method Details

._osObject



7
# File 'lib/panoptimon/util.rb', line 7

def self._os; @os ||= Gem::Platform.local.os.to_sym; end

.os(dispatch = {}) ⇒ Object

return osname or, given a hash, return the corresponding hash element and raise error if os not in hash keys



12
13
14
15
16
17
18
19
20
# File 'lib/panoptimon/util.rb', line 12

def self.os (dispatch={})
  # TODO or mess with rbconfig + Config::CONFIG['host_os']
  os = _os
  return os unless dispatch.length > 0

  it = dispatch[os] || dispatch[:default] or
    raise "unsupported OS: #{os}"
  return it.is_a?(Proc) ? it.call() : it
end