Class: HideMyAss::Proxy
- Inherits:
-
Object
- Object
- HideMyAss::Proxy
- Defined in:
- lib/hidemyass/proxy.rb
Overview
Interface for the attributes of each proxy. Such attributes include the ip, port and protocol.
Instance Method Summary collapse
-
#anonym? ⇒ Boolean
If the proxy’s anonymity is high or even higher.
-
#anonymity ⇒ String
The level of anonymity in downcase letters.
-
#country ⇒ String
The country where the proxy is hosted in downcase letters.
-
#http? ⇒ Boolean
If the proxy’s network protocol is HTTP.
-
#https? ⇒ Boolean
If the proxy’s network protocol is HTTPS.
-
#initialize(row) ⇒ HideMyAss::Proxy
constructor
Initializes the proxy instance by passing a single row of the fetched result list.
-
#inspect ⇒ String
Custom inspect method.
-
#ip ⇒ String
The IP of the proxy server.
-
#last_check ⇒ Int
Time in minutes when its been last checked.
-
#port ⇒ Int
The port for the proxy.
-
#rel_url ⇒ String
The relative URL without the leading protocol.
-
#secure? ⇒ Boolean
If the proxy’s anonymity is at least high and protocol is encrypted.
-
#socks? ⇒ Boolean
If the proxy’s network protocol is SOCKS.
-
#speed ⇒ Int
The average response time in milliseconds.
-
#ssl? ⇒ Boolean
If the proxy supports SSL encryption.
-
#type ⇒ String
(also: #protocol)
The network protocol in in downcase letters.
-
#url ⇒ String
The complete URL of that proxy server.
Constructor Details
#initialize(row) ⇒ HideMyAss::Proxy
Initializes the proxy instance by passing a single row of the fetched result list. All attribute readers are lazy implemented.
32 33 34 |
# File 'lib/hidemyass/proxy.rb', line 32 def initialize(row) @row = row end |
Instance Method Details
#anonym? ⇒ Boolean
If the proxy’s anonymity is high or even higher.
136 137 138 |
# File 'lib/hidemyass/proxy.rb', line 136 def anonym? anonymity.start_with? 'high' end |
#anonymity ⇒ String
The level of anonymity in downcase letters. (low, medium, high, …)
80 81 82 |
# File 'lib/hidemyass/proxy.rb', line 80 def anonymity @anonymity ||= @row.at_xpath('td[6]').text.strip.downcase! end |
#country ⇒ String
The country where the proxy is hosted in downcase letters.
53 54 55 56 |
# File 'lib/hidemyass/proxy.rb', line 53 def country @country ||= @row.at_xpath('td[3]/div/text()') .text.strip.downcase!.scan(/[[:word:]]+$/).last end |
#http? ⇒ Boolean
If the proxy’s network protocol is HTTP.
108 109 110 |
# File 'lib/hidemyass/proxy.rb', line 108 def http? protocol == 'http' end |
#https? ⇒ Boolean
If the proxy’s network protocol is HTTPS.
115 116 117 |
# File 'lib/hidemyass/proxy.rb', line 115 def https? protocol == 'https' end |
#inspect ⇒ String
155 156 157 |
# File 'lib/hidemyass/proxy.rb', line 155 def inspect "<#{self.class.name} #{url}>" end |
#ip ⇒ String
The IP of the proxy server.
39 40 41 |
# File 'lib/hidemyass/proxy.rb', line 39 def ip @ip ||= @row.at_xpath('td[1]/text()').text.strip end |
#last_check ⇒ Int
Time in minutes when its been last checked.
87 88 89 |
# File 'lib/hidemyass/proxy.rb', line 87 def last_check @last_check ||= @row.at_xpath('td[7]/text()').text.scan(/^\d+/)[0].to_i end |
#port ⇒ Int
The port for the proxy.
46 47 48 |
# File 'lib/hidemyass/proxy.rb', line 46 def port @port ||= @row.at_xpath('td[2]/text()').text.strip.to_i end |
#rel_url ⇒ String
The relative URL without the leading protocol.
94 95 96 |
# File 'lib/hidemyass/proxy.rb', line 94 def rel_url "#{ip}:#{port}" end |
#secure? ⇒ Boolean
If the proxy’s anonymity is at least high and protocol is encrypted.
143 144 145 |
# File 'lib/hidemyass/proxy.rb', line 143 def secure? anonym? && ssl? end |
#socks? ⇒ Boolean
If the proxy’s network protocol is SOCKS.
122 123 124 |
# File 'lib/hidemyass/proxy.rb', line 122 def socks? protocol.start_with? 'socks' end |
#speed ⇒ Int
The average response time in milliseconds.
61 62 63 64 |
# File 'lib/hidemyass/proxy.rb', line 61 def speed @speed ||= @row.at_xpath('td[4]/div/div/p/text()') .text.scan(/^\d+/)[0].to_i end |
#ssl? ⇒ Boolean
If the proxy supports SSL encryption.
129 130 131 |
# File 'lib/hidemyass/proxy.rb', line 129 def ssl? https? || socks? end |
#type ⇒ String Also known as: protocol
The network protocol in in downcase letters. (https or http or socks)
70 71 72 |
# File 'lib/hidemyass/proxy.rb', line 70 def type @type ||= @row.at_xpath('td[5]/text()').text.strip.split.last.downcase! end |
#url ⇒ String
The complete URL of that proxy server.
101 102 103 |
# File 'lib/hidemyass/proxy.rb', line 101 def url "#{protocol}://#{rel_url}" end |