File: hello.rb

package info (click to toggle)
r-cran-rinside 0.2.19-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 668 kB
  • sloc: cpp: 3,310; ansic: 117; xml: 57; ruby: 34; makefile: 2
file content (16 lines) | stat: -rw-r--r-- 419 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#~ Hello World in Ruby
#~ Printing is done by R, not Ruby
require 'ffi'

module R
  extend FFI::Library
  libdir = `Rscript -e \'cat(find.package("RInside"))\'`
  ffi_lib "#{libdir}/lib/libRInside.so"
  attach_function :setupRinC, [ ], :void
  attach_function :evalQuietlyInR, [ :string ], :void
  attach_function :teardownRinC, [ ], :void
end

R.setupRinC()
R.evalQuietlyInR("print('Hello from R!')")
R.teardownRinC()