Module: Kernel

Defined in:
lib/cosmos/core_ext/kernel.rb

Overview

COSMOS specific additions to the Ruby Kernel module

Instance Method Summary collapse

Instance Method Details

#calling_method(start = 1) ⇒ Symbol

Returns The name of the calling method.

Parameters:

  • start (Integer) (defaults to: 1)

    The number of stack entries to skip

Returns:

  • (Symbol)

    The name of the calling method



35
36
37
# File 'lib/cosmos/core_ext/kernel.rb', line 35

def calling_method(start = 1)
  caller[start][/`([^']*)'/, 1].intern
end

#is_mac?Boolean

Returns Whether the current platform is Mac.

Returns:

  • (Boolean)

    Whether the current platform is Mac



24
25
26
27
28
29
30
31
# File 'lib/cosmos/core_ext/kernel.rb', line 24

def is_mac?
  _, platform, *_ = RUBY_PLATFORM.split("-")
  result = false
  if platform =~ /darwin/
    result = true
  end
  return result
end

#is_windows?Boolean

Returns Whether the current platform is Windows.

Returns:

  • (Boolean)

    Whether the current platform is Windows



14
15
16
17
18
19
20
21
# File 'lib/cosmos/core_ext/kernel.rb', line 14

def is_windows?
  _, platform, *_ = RUBY_PLATFORM.split("-")
  result = false
  if platform == 'mswin32' or platform == 'mingw32'
    result = true
  end
  return result
end