Method: OpenCPU::Client#execute

Defined in:
lib/opencpu/client.rb

#execute(package, function, options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/opencpu/client.rb', line 13

def execute(package, function, options = {})
  user                      = options.fetch :user, :system
  data                      = options.fetch :data, {}
  format                    = options.fetch :format, :json
  github_remote             = options.fetch :github_remote, false
  should_convert_na_to_nil  = options.fetch :convert_na_to_nil, false

  process_query function_url(package, function, user, github_remote, :json), data, format do |response|
    output = JSON.parse(response.body)
    output = convert_na_to_nil(output) if should_convert_na_to_nil
    output
  end
end