lib/ronin/network/http/proxy.rb in ronin-support-0.2.0 vs lib/ronin/network/http/proxy.rb in ronin-support-0.3.0

- old
+ new

@@ -91,11 +91,11 @@ end host, port = proxy.split(':',2) port = port.to_i if port - return self.new( + return new( :host => host, :port => port, :user => user, :password => password ) @@ -119,22 +119,22 @@ def self.create(proxy) case proxy when Proxy proxy when URI::HTTP - self.new( + new( :host => proxy.host, :port => proxy.port, :user => proxy.user, :password => proxy.password ) when Hash - self.new(proxy) + new(proxy) when String - self.parse(proxy) + parse(proxy) when nil - self.new + new else raise(ArgumentError,"argument must be either a #{self}, URI::HTTP, Hash or String") end end @@ -248,11 +248,11 @@ # Net::HTTP::Proxy. # # @api public # def enabled? - !(self.host.nil?) + !(host.nil?) end # # Builds a HTTP URI from the proxy information. # @@ -263,22 +263,22 @@ # @api public # def url return nil unless enabled? - userinfo = if self.user - if self.password - "#{self.user}:#{self.password}" + userinfo = if user + if password + "#{user}:#{password}" else - self.user + user end end return URI::HTTP.build( :userinfo => userinfo, - :host => self.host, - :port => self.port + :host => host, + :port => port ) end # # Converts the proxy object to a String. @@ -287,11 +287,11 @@ # The host-name of the proxy. # # @api public # def to_s - self.host.to_s + host.to_s end # # Inspects the proxy object. # @@ -299,24 +299,23 @@ # The inspection of the proxy object. # # @api public # def inspect - unless self.host + unless host str = 'disabled' else str = '' - str << self.host.to_s - str << ":#{self.port}" if self.port + str << host.to_s + str << ":#{port}" if port - if self.user + if user auth_str = '' + auth_str << user.to_s - auth_str << self.user.to_s - - if self.password - auth_str << ":#{self.password}" + if password + auth_str << ":#{password}" end str = "#{auth_str}@#{str}" end end