Class: KnitrRuby::Knitr
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- KnitrRuby::Knitr
- Defined in:
- lib/knitr-ruby/knitr.rb
Instance Method Summary collapse
Instance Method Details
#knit(content) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/knitr-ruby/knitr.rb', line 7 def knit(content) dir = File. File.dirname(__FILE__) command = "./knitrscript.R --args #{}" Open3::popen3(command, chdir: dir) do |stdin, stdout, stderr, wait_thr| stdin.puts content stdin.close raise StandardError, "Error knitting: #{stderr.read}" if wait_thr.value.exitstatus > 0 content = stdout.read end end |
#options ⇒ Object
19 20 21 22 |
# File 'lib/knitr-ruby/knitr.rb', line 19 def opts = || {} opts.map {|k,v| "#{k}=#{v}" }.join(" ") end |