Class: Scruber::Helpers::ProxyRotator::Configuration
- Includes:
- Core::Extensions::Loop::CoreMethods
- Defined in:
- lib/scruber/helpers/proxy_rotator.rb
Constant Summary collapse
- AVAILABLE_MODES =
[:random, :round_robin]
Instance Attribute Summary collapse
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#pickup ⇒ Object
readonly
Returns the value of attribute pickup.
-
#proxies ⇒ Object
readonly
Returns the value of attribute proxies.
-
#proxy_keys ⇒ Object
readonly
Returns the value of attribute proxy_keys.
Instance Method Summary collapse
- #add(proxy_address, options = {}) ⇒ Object
- #clean ⇒ Object
- #configure(&block) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #set_mode(mode) ⇒ Object
Methods included from Core::Extensions::Loop::CoreMethods
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
47 48 49 50 51 52 |
# File 'lib/scruber/helpers/proxy_rotator.rb', line 47 def initialize @mode = :round_robin @proxies = {} @proxy_keys = [] @pickup = nil end |
Instance Attribute Details
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
45 46 47 |
# File 'lib/scruber/helpers/proxy_rotator.rb', line 45 def mode @mode end |
#pickup ⇒ Object (readonly)
Returns the value of attribute pickup.
45 46 47 |
# File 'lib/scruber/helpers/proxy_rotator.rb', line 45 def pickup @pickup end |
#proxies ⇒ Object (readonly)
Returns the value of attribute proxies.
45 46 47 |
# File 'lib/scruber/helpers/proxy_rotator.rb', line 45 def proxies @proxies end |
#proxy_keys ⇒ Object (readonly)
Returns the value of attribute proxy_keys.
45 46 47 |
# File 'lib/scruber/helpers/proxy_rotator.rb', line 45 def proxy_keys @proxy_keys end |
Instance Method Details
#add(proxy_address, options = {}) ⇒ Object
63 64 65 66 |
# File 'lib/scruber/helpers/proxy_rotator.rb', line 63 def add(proxy_address, ={}) proxy = Proxy.new(proxy_address, ) @proxies[proxy.id] = proxy end |
#clean ⇒ Object
59 60 61 |
# File 'lib/scruber/helpers/proxy_rotator.rb', line 59 def clean @proxies = {} end |
#configure(&block) ⇒ Object
54 55 56 57 |
# File 'lib/scruber/helpers/proxy_rotator.rb', line 54 def configure(&block) instance_eval &block rebuild_caches end |
#set_mode(mode) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/scruber/helpers/proxy_rotator.rb', line 68 def set_mode(mode) if AVAILABLE_MODES.include?(mode) @mode = mode else raise Scruber::ArgumentError.new("Wrong mode. Available modes: #{AVAILABLE_MODES}") end end |