class HideMyAss::Proxy::Base
Interface for the attributes of each proxy. Such attributes include the ip, port and protocol.
@example Get the proxy's ip address.
proxy.ip # => '178.22.148.122'
@example Get the proxy's port.
proxy.port # => 3129
@example Get the proxy's protocol.
proxy.protocol # => 'HTTPS'
@example Get the hosted country.
proxy.country # => 'FRANCE'
@example Get the complete url.
proxy.url # => 'https://178.22.148.122:3129'
Attributes
Raw data of the row element.
@return [ Object ]
Public Class Methods
Initializes the proxy instance by passing a single row of the fetched result list. All attribute readers are lazy implemented.
@param [ Object ] row Pre-parsed row element.
@return [ HideMyAss::Proxy::Base
]
# File lib/hidemyass/proxy/base.rb, line 33 def initialize(row) @row = row end
Public Instance Methods
If the proxy's anonymity is high or even higher.
@return [ Boolean ]
# File lib/hidemyass/proxy/base.rb, line 95 def anonym? anonymity.start_with? 'high' end
If the proxy's network protocol is HTTP.
@return [ Boolean ]
# File lib/hidemyass/proxy/base.rb, line 67 def http? protocol == 'http' end
If the proxy's network protocol is HTTPS.
@return [ Boolean ]
# File lib/hidemyass/proxy/base.rb, line 74 def https? protocol == 'https' end
Custom inspect method.
@example
inspect
> '<HideMyAss::Proxy 123.57.52.171:80>'¶ ↑
@return [ String ] :nocov:
# File lib/hidemyass/proxy/base.rb, line 114 def inspect "<#{self.class.name} #{url}>" end
The network protocol in in downcase letters. (https or http or socks)
@return [ String ]
# File lib/hidemyass/proxy/base.rb, line 46 def protocol type end
The relative URL without the leading protocol.
@return [ String ]
# File lib/hidemyass/proxy/base.rb, line 53 def rel_url "#{ip}:#{port}" end
If the proxy's anonymity is at least high and protocol is encrypted.
@return [ Boolean ]
# File lib/hidemyass/proxy/base.rb, line 102 def secure? anonym? && ssl? end
If the proxy's network protocol is SOCKS.
@return [ Boolean ]
# File lib/hidemyass/proxy/base.rb, line 81 def socks? protocol.start_with? 'socks' end
If the proxy supports SSL encryption.
@return [ Boolean ]
# File lib/hidemyass/proxy/base.rb, line 88 def ssl? https? || socks? end
The complete URL of that proxy server.
@return [ String ]
# File lib/hidemyass/proxy/base.rb, line 60 def url "#{protocol}://#{rel_url}" end