Class: ProxyManager
- Inherits:
-
Object
- Object
- 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.
7 8 9 10 11 12 13 |
# File 'lib/insta/proxy_manager.rb', line 7 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.
4 5 6 |
# File 'lib/insta/proxy_manager.rb', line 4 def proxys @proxys end |
Instance Method Details
#next ⇒ Object
15 16 17 18 19 20 |
# File 'lib/insta/proxy_manager.rb', line 15 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 |