Class: Insta::ProxyManager
- Inherits:
-
Object
- Object
- Insta::ProxyManager
- Defined in:
- lib/insta/proxy_manager.rb
Instance Attribute Summary collapse
-
#proxies ⇒ Object
Returns the value of attribute proxies.
Instance Method Summary collapse
-
#initialize(proxies = []) ⇒ ProxyManager
constructor
A new instance of ProxyManager.
- #next ⇒ Object
Constructor Details
#initialize(proxies = []) ⇒ ProxyManager
Returns a new instance of ProxyManager.
8 9 10 11 12 13 14 |
# File 'lib/insta/proxy_manager.rb', line 8 def initialize(proxies = []) proxies.each do |proxy| proxy[:id] = SecureRandom.uuid proxy[:last_use] = nil end @proxies = proxies end |
Instance Attribute Details
#proxies ⇒ Object
Returns the value of attribute proxies.
5 6 7 |
# File 'lib/insta/proxy_manager.rb', line 5 def proxies @proxies end |
Instance Method Details
#next ⇒ Object
16 17 18 19 20 21 |
# File 'lib/insta/proxy_manager.rb', line 16 def next return nil if @proxies.nil? || @proxies.empty? next_proxy = @proxies.sort_by { |proxy| proxy[:last_use] }.first next_proxy[:last_use] = Time.now next_proxy end |