Module: Rust
- Defined in:
- lib/rust-core.rb
Defined Under Namespace
Modules: Descriptive, EffectSize, RBindings, StatisticalTests
Constant Summary
collapse
- CLIENT_MUTEX =
Mutex.new
- R_MUTEX =
Mutex.new
- R_ENGINE =
RinRuby.new(echo: false)
- @@in_client_mutex =
false
Class Method Summary
collapse
Class Method Details
._eval(r_command, return_warnings = false) ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/rust-core.rb', line 44
def self._eval(r_command, return_warnings = false)
R_MUTEX.synchronize do
assert("This command must be executed in an exclusive block") { @@in_client_mutex }
$stdout = StringIO.new
if return_warnings
R_ENGINE.echo(true, true)
else
R_ENGINE.echo(false, false)
end
result = R_ENGINE.eval(r_command)
R_ENGINE.echo(false, false)
warnings = $stdout.string
$stdout = STDOUT
if return_warnings
return result, warnings.lines.map { |w| w.strip.chomp }
else
return result
end
end
end
|
._pull(r_command, return_warnings = false) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/rust-core.rb', line 21
def self._pull(r_command, return_warnings = false)
R_MUTEX.synchronize do
assert("This command must be executed in an exclusive block") { @@in_client_mutex }
$stdout = StringIO.new
if return_warnings
R_ENGINE.echo(true, true)
else
R_ENGINE.echo(false, false)
end
result = R_ENGINE.pull(r_command)
R_ENGINE.echo(false, false)
warnings = $stdout.string
$stdout = STDOUT
if return_warnings
return result, warnings.lines.map { |w| w.strip.chomp }
else
return result
end
end
end
|
.exclusive ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/rust-core.rb', line 13
def self.exclusive
CLIENT_MUTEX.synchronize do
@@in_client_mutex = true
yield
@@in_client_mutex = false
end
end
|