Class: Evalso::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/evalso.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, hash) ⇒ Response

Returns a new instance of Response.



109
110
111
112
113
114
115
116
117
118
# File 'lib/evalso.rb', line 109

def initialize(code, hash)
  @code   = code
  @stdout = hash["stdout"]
  @stderr = hash["stderr"]
  @return = hash["return"]
  @wall_time = hash["wallTime"]
  @exit_code = hash["exitCode"]
  @output_files = handle_output_files(hash["outputFiles"] || {})
  @compilation_result = hash["compilationResult"]
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



106
107
108
# File 'lib/evalso.rb', line 106

def code
  @code
end

#compilation_resultObject (readonly)

Returns the value of attribute compilation_result.



106
107
108
# File 'lib/evalso.rb', line 106

def compilation_result
  @compilation_result
end

#output_filesObject (readonly)

Returns the value of attribute output_files.



106
107
108
# File 'lib/evalso.rb', line 106

def output_files
  @output_files
end

#remaining_evaluationsObject (readonly)

Returns the value of attribute remaining_evaluations.



106
107
108
# File 'lib/evalso.rb', line 106

def remaining_evaluations
  @remaining_evaluations
end

#returnObject (readonly)

Returns the value of attribute return.



106
107
108
# File 'lib/evalso.rb', line 106

def return
  @return
end

#stderrObject (readonly)

Returns the value of attribute stderr.



106
107
108
# File 'lib/evalso.rb', line 106

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



106
107
108
# File 'lib/evalso.rb', line 106

def stdout
  @stdout
end

#wall_timeObject (readonly)

Returns the value of attribute wall_time.



106
107
108
# File 'lib/evalso.rb', line 106

def wall_time
  @wall_time
end

Instance Method Details

#handle_output_files(files) ⇒ Object



120
121
122
123
124
# File 'lib/evalso.rb', line 120

def handle_output_files(files)
  files.keys.each do |file|
    files[file] = Base64.decode64(files[file])
  end
end

#inspectObject



126
127
128
# File 'lib/evalso.rb', line 126

def inspect
  "#<#{self.class.name} code=#{code.inspect} stdout=#{stdout.inspect} stderr=#{stderr.inspect} wall_time=#{wall_time.inspect}>"
end

#to_jsonObject



130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/evalso.rb', line 130

def to_json
  {
    code:     @code,
    stdout:   @stdout,
    stderr:   @stderr,
    return:   @return,
    wall_time: @wall_time,
    exit_code: @exit_code,
    output_files: @output_files,
    compilation_result: @compilation_result,
  }.to_json
end