Class: OcpuCallback

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_cpu/models/ocpu_callback.rb

Constant Summary collapse

VALUE_LOCATION =
0
STDOUT_LOCATION =
1
SOURCE_LOCATION =
2
CONSOLE_LOCATION =
3
INFO_LOCATION =
4

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#consoleObject

Returns the value of attribute console.



6
7
8
# File 'lib/ruby_cpu/models/ocpu_callback.rb', line 6

def console
  @console
end

#infoObject

Returns the value of attribute info.



7
8
9
# File 'lib/ruby_cpu/models/ocpu_callback.rb', line 7

def info
  @info
end

#session_codeObject

Returns the value of attribute session_code.



8
9
10
# File 'lib/ruby_cpu/models/ocpu_callback.rb', line 8

def session_code
  @session_code
end

#sourceObject

Returns the value of attribute source.



5
6
7
# File 'lib/ruby_cpu/models/ocpu_callback.rb', line 5

def source
  @source
end

#stdoutObject

Returns the value of attribute stdout.



4
5
6
# File 'lib/ruby_cpu/models/ocpu_callback.rb', line 4

def stdout
  @stdout
end

#valueObject

Returns the value of attribute value.



3
4
5
# File 'lib/ruby_cpu/models/ocpu_callback.rb', line 3

def value
  @value
end

Class Method Details

.build_from_response(response_urls) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ruby_cpu/models/ocpu_callback.rb', line 16

def self.build_from_response response_urls
  
  response_urls = response_urls.split("\n")
  
  ocpu_callback = new
  
  if response_urls.length >= 5 then
    
    ocpu_callback.value = response_urls[OcpuCallback::VALUE_LOCATION].trim "/"
    
    ocpu_callback.stdout = response_urls[OcpuCallback::STDOUT_LOCATION].trim "/"
    
    ocpu_callback.source = response_urls[OcpuCallback::SOURCE_LOCATION].trim "/"
    
    ocpu_callback.console = response_urls[OcpuCallback::CONSOLE_LOCATION].trim "/"
    
    ocpu_callback.info = response_urls[OcpuCallback::INFO_LOCATION].trim "/"
    
    ocpu_callback.session_code = ocpu_callback.value.split("/")[3]
    
  end
  
  ocpu_callback
  
end