Class: Algorithmia::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, output_type) ⇒ Response

Returns a new instance of Response.



7
8
9
10
# File 'lib/algorithmia/response.rb', line 7

def initialize(response, output_type)
  @response = response
  @output_type = output_type
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



5
6
7
# File 'lib/algorithmia/response.rb', line 5

def response
  @response
end

Instance Method Details

#alertsObject



54
55
56
57
58
59
60
# File 'lib/algorithmia/response.rb', line 54

def alerts
  if @output_type == 'raw'
    nil
  else
    ["alerts"]
  end
end

#content_typeObject



38
39
40
41
42
43
44
# File 'lib/algorithmia/response.rb', line 38

def content_type
  if @output_type == 'raw'
    nil
  else
    ["content_type"]
  end
end

#durationObject



30
31
32
33
34
35
36
# File 'lib/algorithmia/response.rb', line 30

def duration
  if @output_type == 'raw'
    nil
  else
    ["duration"]
  end
end

#metadataObject



22
23
24
25
26
27
28
# File 'lib/algorithmia/response.rb', line 22

def 
  if @output_type == 'raw'
    nil
  else
    @response["metadata"]
  end
end

#resultObject



12
13
14
15
16
17
18
19
20
# File 'lib/algorithmia/response.rb', line 12

def result
  if @output_type == 'raw'
    @response
  elsif content_type == 'binary'
    Base64.decode64(@response["result"])
  else
    @response["result"]
  end
end

#stdoutObject



46
47
48
49
50
51
52
# File 'lib/algorithmia/response.rb', line 46

def stdout
  if @output_type == 'raw'
    nil
  else
    ["stdout"]
  end
end