Class: Yarr::EvaluatorService::Request

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

Overview

Request that's sent to web service.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, lang = nil) ⇒ Request

Creates a new Request to be sent for evaluation

Parameters:

  • code (String|nil)

    code to be evaluated

  • lang (String|nil) (defaults to: nil)

    Ruby version


38
39
40
41
# File 'lib/yarr/evaluator_service.rb', line 38

def initialize(code, lang = nil)
  @code = code
  @lang = lang
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code


32
33
34
# File 'lib/yarr/evaluator_service.rb', line 32

def code
  @code
end

#langObject (readonly)

Returns the value of attribute lang


32
33
34
# File 'lib/yarr/evaluator_service.rb', line 32

def lang
  @lang
end

Instance Method Details

#to_wireObject

Serializes the request ready to be sent


44
45
46
47
48
49
50
# File 'lib/yarr/evaluator_service.rb', line 44

def to_wire
  { run_request: {
    language: 'ruby',
    version: @lang,
    code: @code
  } }.to_json
end