Class: Clients::ProxyListClient
- Inherits:
-
Object
- Object
- Clients::ProxyListClient
- Defined in:
- lib/clients/proxy_list_client.rb
Constant Summary collapse
- DEFAULT_LIST_PATH =
"/tmp/clients_proxy_list.txt".freeze
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path = DEFAULT_LIST_PATH) ⇒ ProxyListClient
constructor
A new instance of ProxyListClient.
- #port ⇒ Object
- #reset! ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(path = DEFAULT_LIST_PATH) ⇒ ProxyListClient
Returns a new instance of ProxyListClient.
13 14 15 16 |
# File 'lib/clients/proxy_list_client.rb', line 13 def initialize(path = DEFAULT_LIST_PATH) @path = path select_proxy_from_list end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
5 6 7 |
# File 'lib/clients/proxy_list_client.rb', line 5 def host @host end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
5 6 7 |
# File 'lib/clients/proxy_list_client.rb', line 5 def password @password end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
5 6 7 |
# File 'lib/clients/proxy_list_client.rb', line 5 def user @user end |
Class Method Details
.cache_list(list_url, list_path = DEFAULT_LIST_PATH) ⇒ Object
7 8 9 10 11 |
# File 'lib/clients/proxy_list_client.rb', line 7 def self.cache_list(list_url, list_path = DEFAULT_LIST_PATH) response = HTTP.get(list_url) fail "Invalid list response: #{response.status}" unless response.status.success? File.open(list_path, "w") { |f| f << response.to_s } end |
Instance Method Details
#port ⇒ Object
18 19 20 |
# File 'lib/clients/proxy_list_client.rb', line 18 def port @port.to_i end |
#reset! ⇒ Object
26 27 28 |
# File 'lib/clients/proxy_list_client.rb', line 26 def reset! select_proxy_from_list end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/clients/proxy_list_client.rb', line 22 def to_s [host, port, user, password].compact.join(":") end |