class Docker::API::Response
Reponse class.
Attributes
json[R]
path[R]
Public Class Methods
new(data)
click to toggle source
Initialize a new Response
object.
@params data [Object]: Reponse's data.
Calls superclass method
# File lib/docker/api/response.rb, line 10 def initialize data super data @json = parse_json @body @path = @data[:path] end
Public Instance Methods
success?()
click to toggle source
Return true if Response
status is in 200..204 range.
# File lib/docker/api/response.rb, line 18 def success? (200..204).include? @status end
Private Instance Methods
parse_json(data)
click to toggle source
Create a json from Response
data attribute.
@params data [String]: String to be converted in json.
# File lib/docker/api/response.rb, line 28 def parse_json data return nil unless headers["Content-Type"] == "application/json" return nil if data == "" data.split("\r\n").size > 1 ? data.split("\r\n").map{ |e| eval(e) } : JSON.parse(data) end