module Rust
Constants
- CLIENT_MUTEX
- R_ENGINE
- R_MUTEX
Public Class Methods
[](variable, type=RustDatatype)
click to toggle source
# File lib/rust-core.rb, line 44 def self.[](variable, type=RustDatatype) return type.pull_variable(variable) end
[]=(variable, value)
click to toggle source
# File lib/rust-core.rb, line 33 def self.[]=(variable, value) if value.is_a?(RustDatatype) value.load_in_r_as(variable.to_s) elsif value.is_a?(String) || value.is_a?(Numeric) || value.is_a?(Array) R_ENGINE.assign(variable, value) else raise "Given #{value.class}, expected RustDatatype, String, Numeric, or Array" end end
_eval(r_command, return_warnings = false)
click to toggle source
# File lib/rust-core.rb, line 73 def self._eval(r_command, return_warnings = false) self._rexec(r_command, return_warnings) { |cmd| R_ENGINE.eval(cmd) } end
_eval_big(r_command, return_warnings = false)
click to toggle source
# File lib/rust-core.rb, line 48 def self._eval_big(r_command, return_warnings = false) r_command = r_command.join("\n") if r_command.is_a?(Array) self._rexec(r_command, return_warnings) do |cmd| result = true instructions = cmd.lines while instructions.size > 0 current_command = "" while (instructions.size > 0) && (current_command.length + instructions.first.length < 10000) current_command << instructions.shift end result &= R_ENGINE.eval(current_command) end result end end
_pull(r_command, return_warnings = false)
click to toggle source
# File lib/rust-core.rb, line 69 def self._pull(r_command, return_warnings = false) self._rexec(r_command, return_warnings) { |cmd| R_ENGINE.pull(cmd) } end
_rexec(r_command, return_warnings = false) { |r_command| ... }
click to toggle source
# File lib/rust-core.rb, line 77 def self._rexec(r_command, return_warnings = false) puts "Calling _rexec with command: #{r_command}" if @@debugging R_MUTEX.synchronize do assert("This command must be executed in an exclusive block") { @@in_client_mutex } result = nil begin $stdout = StringIO.new if return_warnings R_ENGINE.echo(true, true) else R_ENGINE.echo(false, false) end result = yield(r_command) ensure R_ENGINE.echo(false, false) warnings = $stdout.string $stdout = STDOUT end if return_warnings return result, warnings.lines.map { |w| w.strip.chomp } else return result end end end
debug()
click to toggle source
# File lib/rust-core.rb, line 19 def self.debug @@debugging = true end
exclusive() { || ... }
click to toggle source
# File lib/rust-core.rb, line 23 def self.exclusive result = nil CLIENT_MUTEX.synchronize do @@in_client_mutex = true result = yield @@in_client_mutex = false end return result end