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