Module: RType::R

Defined in:
lib/r_type/r.rb

Class Method Summary collapse

Class Method Details

.init_rsrubyObject



36
37
38
39
40
41
42
# File 'lib/r_type/r.rb', line 36

def init_rsruby
  RSRuby.set_default_mode RSRuby::PROC_CONVERSION
  converter = RType::Convert.new
  @rsruby = RSRuby.instance
  @rsruby.proc_table[->(x){ true }] = ->(x) { converter.convert x }
  @rsruby
end

.lazy_expression(r_exp) ⇒ Object Also known as: `



27
28
29
# File 'lib/r_type/r.rb', line 27

def lazy_expression r_exp
  rsruby.eval_R "quote(#{r_exp})"
end

.method_missing(name, *args, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/r_type/r.rb', line 4

def method_missing name, *args, &block
  if name =~ /^(.*)=$/
    rsruby[:assign].call $1.to_s, args.first
  elsif rsruby.respond_to? name
    rsruby.send name, *args
  else
    obj = rsruby[name]
    if obj.is_a?(::RType::Function)
      obj.call *args
    else
      obj
    end
  end
end


23
24
25
# File 'lib/r_type/r.rb', line 23

def print *args
  rsruby[:print].call *args
end

.rsrubyObject



32
33
34
# File 'lib/r_type/r.rb', line 32

def rsruby
  @rsruby ||= init_rsruby
end

.run(&block) ⇒ Object



19
20
21
# File 'lib/r_type/r.rb', line 19

def run &block
  instance_eval &block
end