Module: Spark::Helper::System::Methods

Defined in:
lib/spark/helper/system.rb

Instance Method Summary collapse

Instance Method Details

#jruby?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/spark/helper/system.rb', line 19

def jruby?
  RbConfig::CONFIG['ruby_install_name'] == 'jruby'
end

#memory_usageObject

Memory usage in kb



28
29
30
31
32
33
34
35
36
37
# File 'lib/spark/helper/system.rb', line 28

def memory_usage
  if jruby?
    runtime = java.lang.Runtime.getRuntime
    (runtime.totalMemory - runtime.freeMemory) >> 10
  elsif windows?
    # not yet
  else
    `ps -o rss= -p #{Process.pid}`.to_i
  end
end

#mri?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/spark/helper/system.rb', line 15

def mri?
  RbConfig::CONFIG['ruby_install_name'] == 'ruby'
end

#pry?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/spark/helper/system.rb', line 23

def pry?
  !!Thread.current[:__pry__]
end

#windows?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/spark/helper/system.rb', line 11

def windows?
  RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
end