lib/url/response.rb in url-0.2.2 vs lib/url/response.rb in url-0.3.0
- old
+ new
@@ -1,7 +1,5 @@
-require "delegate"
-
class URL
# The Response class is a deleegate to string which also contains metadata about the request.
# These methods are also available
# * body
@@ -24,19 +22,29 @@
attr_reader :response
# The url which generated this response
# @returns [String]
attr_reader :url
+
+ # The url object used to create the response
+ # @returns [URL]
+ attr_reader :url_obj
+
+ # This is set to true if the target server was not reachable
+ # @returns [Boolean]
+ def connection_refused
+ @connection_refused || code == 0
+ end
# @param [String] body The body of the response object, main string
# @param [Hash] args Additional arguments: :time,:code,:response,:url
def initialize(str,args={})
if str.is_a?(Hash)
args = str
str = args[:body]
end
- raise unless str
+ raise ArgumentError, "No string provided" unless str
super(str)
args.each do |key, value|
instance_variable_set "@#{key}", value
end
end
\ No newline at end of file