Class: Rextester

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/rextester.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lang_id: 12, code: '', input: '', compiler_args: '') ⇒ Rextester

Returns a new instance of Rextester.



9
10
11
12
13
14
# File 'lib/rextester.rb', line 9

def initialize(lang_id: 12, code: '', input: '', compiler_args: '')
  @options = { 'LanguageChoice': lang_id,
               'Program': code,
               'Input': input,
               'CompilerArgs': compiler_args }
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



7
8
9
# File 'lib/rextester.rb', line 7

def errors
  @errors
end

#mem_peakObject (readonly)

Returns the value of attribute mem_peak.



7
8
9
# File 'lib/rextester.rb', line 7

def mem_peak
  @mem_peak
end

#resultObject (readonly)

Returns the value of attribute result.



7
8
9
# File 'lib/rextester.rb', line 7

def result
  @result
end

#run_timeObject (readonly)

Returns the value of attribute run_time.



7
8
9
# File 'lib/rextester.rb', line 7

def run_time
  @run_time
end

#warningsObject (readonly)

Returns the value of attribute warnings.



7
8
9
# File 'lib/rextester.rb', line 7

def warnings
  @warnings
end

Instance Method Details

#runObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rextester.rb', line 16

def run
  response = request.parsed_response
  return if response['Errors'] == 'Too many requests...'

  @run_time = response['Stats'][23..25].to_f
  @mem_peak = response['Stats'][65..90].to_i

  @errors = response['Errors']
  @warnings = response['Warnings']
  @result = response['Result']
end