Class: Jirarest2::Result
- Inherits:
-
Object
- Object
- Jirarest2::Result
- Defined in:
- lib/jirarest2/result.rb
Overview
An object of Result contians the result of a Net::HTTP REST request that has a JSON-Body with easily accessable parameters.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
The original body of the result.
-
#code ⇒ Object
readonly
The statuscode of the result.
-
#header ⇒ Object
readonly
header lines.
-
#result ⇒ Object
readonly
The JSON part of the body.
Instance Method Summary collapse
-
#initialize(httpResponse) ⇒ Result
constructor
Show the result in a more usable form.
Constructor Details
#initialize(httpResponse) ⇒ Result
Show the result in a more usable form
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/jirarest2/result.rb', line 39 def initialize(httpResponse) @code = httpResponse.code @header = httpResponse.to_hash @body = httpResponse.body if httpResponse.instance_of?(Net::HTTPNoContent) or httpResponse.body == "" or httpResponse.body.nil? then # If there is nothing in the body it would be hard to parse it. @result = @body else @result = JSON.parse(@body) end end |
Instance Attribute Details
#body ⇒ Object (readonly)
The original body of the result
32 33 34 |
# File 'lib/jirarest2/result.rb', line 32 def body @body end |
#code ⇒ Object (readonly)
The statuscode of the result
28 29 30 |
# File 'lib/jirarest2/result.rb', line 28 def code @code end |
#header ⇒ Object (readonly)
header lines
30 31 32 |
# File 'lib/jirarest2/result.rb', line 30 def header @header end |
#result ⇒ Object (readonly)
The JSON part of the body
34 35 36 |
# File 'lib/jirarest2/result.rb', line 34 def result @result end |