Class: Algorithmia::Response
- Inherits:
-
Object
- Object
- Algorithmia::Response
- Defined in:
- lib/algorithmia/response.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #alerts ⇒ Object
- #content_type ⇒ Object
- #duration ⇒ Object
-
#initialize(response, output_type) ⇒ Response
constructor
A new instance of Response.
- #metadata ⇒ Object
- #result ⇒ Object
- #stdout ⇒ Object
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
#response ⇒ Object (readonly)
Returns the value of attribute response.
5 6 7 |
# File 'lib/algorithmia/response.rb', line 5 def response @response end |
Instance Method Details
#alerts ⇒ Object
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_type ⇒ Object
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 |
#duration ⇒ Object
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 |
#metadata ⇒ Object
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 |
#result ⇒ Object
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 |
#stdout ⇒ Object
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 |