class WebFetch::Response
Attributes
body[R]
error[R]
headers[R]
request[R]
response_time[R]
status[R]
uid[R]
Public Class Methods
new(response)
click to toggle source
# File lib/web_fetch/response.rb, line 7 def initialize(response) @pending = response.fetch(:pending, false) return if pending? outcome = response.fetch(:request) @uid = outcome.fetch(:uid) @response_time = outcome.fetch(:response_time, nil) @request = Request.from_hash(outcome.fetch(:request), validate: false) initialize_response(outcome.fetch(:response)) end
Public Instance Methods
complete?()
click to toggle source
# File lib/web_fetch/response.rb, line 32 def complete? !pending? end
initialize_response(response)
click to toggle source
# File lib/web_fetch/response.rb, line 18 def initialize_response(response) @body = Base64.decode64(response.fetch(:body)) @headers = response.fetch(:headers) @status = response.fetch(:status) @success = response.fetch(:success) @error = response.fetch(:error, nil) end
pending?()
click to toggle source
# File lib/web_fetch/response.rb, line 26 def pending? return false if @pending.nil? @pending end
success?()
click to toggle source
# File lib/web_fetch/response.rb, line 36 def success? @success end