Class: Markdownplus::Julia::JuliaHandler

Inherits:
Handler
  • Object
show all
Defined in:
lib/markdownplus/julia.rb

Instance Method Summary collapse

Instance Method Details

#execute(input, parameters, variables, warnings, errors) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/markdownplus/julia.rb', line 7

def execute(input, parameters, variables, warnings, errors)
  output = nil
  file = Tempfile.new(['julia-script','.jl'])
  begin
    parameters.each_with_index do |param,i|
      if param.respond_to?(:to_julia)
        file.write(param.to_julia)
      else
        warnings << "Parameter [#{i}] does not respond to to_julia"
      end
    end
    file.write(input)
    file.close
    output = `julia #{file.path}`
    output.gsub!(/\n\s+/,"\n")
  ensure
    # file.unlink
  end
  output
end