Class: Judge0::Submission
- Inherits:
-
Object
- Object
- Judge0::Submission
- Defined in:
- lib/submission.rb
Instance Attribute Summary collapse
-
#compile_out ⇒ Object
readonly
Returns the value of attribute compile_out.
-
#cpu_extra_time ⇒ Object
Returns the value of attribute cpu_extra_time.
-
#cpu_time_limit ⇒ Object
Returns the value of attribute cpu_time_limit.
-
#enable_per_process_and_thread_memory_limit ⇒ Object
Returns the value of attribute enable_per_process_and_thread_memory_limit.
-
#enable_per_process_and_thread_time_limit ⇒ Object
Returns the value of attribute enable_per_process_and_thread_time_limit.
-
#expected_output ⇒ Object
Returns the value of attribute expected_output.
-
#language_id ⇒ Object
Returns the value of attribute language_id.
-
#max_file_size ⇒ Object
Returns the value of attribute max_file_size.
-
#max_processes_and_or_threads ⇒ Object
Returns the value of attribute max_processes_and_or_threads.
-
#memory ⇒ Object
readonly
Returns the value of attribute memory.
-
#memory_limit ⇒ Object
Returns the value of attribute memory_limit.
-
#number_of_runs ⇒ Object
Returns the value of attribute number_of_runs.
-
#source_code ⇒ Object
Returns the value of attribute source_code.
-
#stack_limit ⇒ Object
Returns the value of attribute stack_limit.
-
#status_description ⇒ Object
readonly
Returns the value of attribute status_description.
-
#status_id ⇒ Object
readonly
Returns the value of attribute status_id.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdin ⇒ Object
Returns the value of attribute stdin.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#wall_time_limit ⇒ Object
Returns the value of attribute wall_time_limit.
Instance Method Summary collapse
-
#initialize(options = {}) {|_self| ... } ⇒ Submission
constructor
A new instance of Submission.
- #result ⇒ Object
- #run ⇒ Object
- #tests_battery(tests) ⇒ Object
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Submission
Returns a new instance of Submission.
14 15 16 17 18 19 |
# File 'lib/submission.rb', line 14 def initialize( = {}) .each do |key, value| instance_variable_set("@#{key}", value) end yield(self) if block_given? end |
Instance Attribute Details
#compile_out ⇒ Object (readonly)
Returns the value of attribute compile_out.
11 12 13 |
# File 'lib/submission.rb', line 11 def compile_out @compile_out end |
#cpu_extra_time ⇒ Object
Returns the value of attribute cpu_extra_time.
3 4 5 |
# File 'lib/submission.rb', line 3 def cpu_extra_time @cpu_extra_time end |
#cpu_time_limit ⇒ Object
Returns the value of attribute cpu_time_limit.
3 4 5 |
# File 'lib/submission.rb', line 3 def cpu_time_limit @cpu_time_limit end |
#enable_per_process_and_thread_memory_limit ⇒ Object
Returns the value of attribute enable_per_process_and_thread_memory_limit.
3 4 5 |
# File 'lib/submission.rb', line 3 def enable_per_process_and_thread_memory_limit @enable_per_process_and_thread_memory_limit end |
#enable_per_process_and_thread_time_limit ⇒ Object
Returns the value of attribute enable_per_process_and_thread_time_limit.
3 4 5 |
# File 'lib/submission.rb', line 3 def enable_per_process_and_thread_time_limit @enable_per_process_and_thread_time_limit end |
#expected_output ⇒ Object
Returns the value of attribute expected_output.
3 4 5 |
# File 'lib/submission.rb', line 3 def expected_output @expected_output end |
#language_id ⇒ Object
Returns the value of attribute language_id.
3 4 5 |
# File 'lib/submission.rb', line 3 def language_id @language_id end |
#max_file_size ⇒ Object
Returns the value of attribute max_file_size.
3 4 5 |
# File 'lib/submission.rb', line 3 def max_file_size @max_file_size end |
#max_processes_and_or_threads ⇒ Object
Returns the value of attribute max_processes_and_or_threads.
3 4 5 |
# File 'lib/submission.rb', line 3 def max_processes_and_or_threads @max_processes_and_or_threads end |
#memory ⇒ Object (readonly)
Returns the value of attribute memory.
11 12 13 |
# File 'lib/submission.rb', line 11 def memory @memory end |
#memory_limit ⇒ Object
Returns the value of attribute memory_limit.
3 4 5 |
# File 'lib/submission.rb', line 3 def memory_limit @memory_limit end |
#number_of_runs ⇒ Object
Returns the value of attribute number_of_runs.
3 4 5 |
# File 'lib/submission.rb', line 3 def number_of_runs @number_of_runs end |
#source_code ⇒ Object
Returns the value of attribute source_code.
3 4 5 |
# File 'lib/submission.rb', line 3 def source_code @source_code end |
#stack_limit ⇒ Object
Returns the value of attribute stack_limit.
3 4 5 |
# File 'lib/submission.rb', line 3 def stack_limit @stack_limit end |
#status_description ⇒ Object (readonly)
Returns the value of attribute status_description.
11 12 13 |
# File 'lib/submission.rb', line 11 def status_description @status_description end |
#status_id ⇒ Object (readonly)
Returns the value of attribute status_id.
11 12 13 |
# File 'lib/submission.rb', line 11 def status_id @status_id end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
11 12 13 |
# File 'lib/submission.rb', line 11 def stderr @stderr end |
#stdin ⇒ Object
Returns the value of attribute stdin.
3 4 5 |
# File 'lib/submission.rb', line 3 def stdin @stdin end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
11 12 13 |
# File 'lib/submission.rb', line 11 def stdout @stdout end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
11 12 13 |
# File 'lib/submission.rb', line 11 def time @time end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
11 12 13 |
# File 'lib/submission.rb', line 11 def token @token end |
#wall_time_limit ⇒ Object
Returns the value of attribute wall_time_limit.
3 4 5 |
# File 'lib/submission.rb', line 3 def wall_time_limit @wall_time_limit end |
Instance Method Details
#result ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/submission.rb', line 55 def result { stdout: @stdout, time: @time, memory: @memory, stderr: @stderr, compile_out: @compile_out, message: , status: { id: @status_id, description: @status_description } } end |
#run ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/submission.rb', line 21 def run res = wait_response(get_token) @stdout = res['stdout'] @time = res['time'].to_f @memory = res['memory'] @stderr = res['stderr'] @compile_out = res['compile_out'] = res['message'] @status_id = res['status']['id'] @status_description = res['status']['description'] result end |
#tests_battery(tests) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/submission.rb', line 36 def tests_battery (tests) tests.map! do |test| if test.respond_to?(:input) && test.respond_to?(:output) @stdin = test.input @expected_output = test.output elsif test.include?(:input) && test.respond_to?(:output) @stdin = test[:input] @expected_output = test[:output] else @stdin = test[0] @expected_output = test[1] end get_token end tests.map do |test| wait_response(test) end end |