Class: Twitterscraper::Proxy::Pool

Inherits:
Object
  • Object
show all
Defined in:
lib/twitterscraper/proxy.rb

Instance Method Summary collapse

Constructor Details

#initializePool

Returns a new instance of Pool.



10
11
12
13
# File 'lib/twitterscraper/proxy.rb', line 10

def initialize
  @items = Proxy.get_proxies
  @cur_index = 0
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/twitterscraper/proxy.rb', line 27

def empty?
  @items.empty?
end

#sampleObject



15
16
17
18
19
20
21
# File 'lib/twitterscraper/proxy.rb', line 15

def sample
  if @cur_index >= @items.size
    reload
  end
  @cur_index += 1
  @items[@cur_index - 1]
end

#sizeObject



23
24
25
# File 'lib/twitterscraper/proxy.rb', line 23

def size
  @items.size
end