Class: R

Inherits:
Object
  • Object
show all
Defined in:
lib/raka/lang/r/impl.rb

Overview

r language protocol

Instance Method Summary collapse

Constructor Details

#initialize(libs = [], **kwargs) ⇒ R

Returns a new instance of R.



7
8
9
10
# File 'lib/raka/lang/r/impl.rb', line 7

def initialize(libs = [], **kwargs)
  @libs = libs
  super(**kwargs)
end

Instance Method Details

#build(code, _) ⇒ Object



12
13
14
15
16
# File 'lib/raka/lang/r/impl.rb', line 12

def build(code, _)
  libraries = @libs.map { |name| "suppressPackageStartupMessages(library(#{name}))" }

  [libraries, code].join "\n"
end

#run_script(env, fname, _task) ⇒ Object



18
19
20
# File 'lib/raka/lang/r/impl.rb', line 18

def run_script(env, fname, _task)
  env.send :sh, "Rscript #{fname}"
end