Class: Screener

Inherits:
Object
  • Object
show all
Defined in:
lib/finviz_rails/screener.rb

Instance Method Summary collapse

Constructor Details

#initialize(agent, auth, *params) ⇒ Screener

Returns a new instance of Screener.



2
3
4
5
6
7
# File 'lib/finviz_rails/screener.rb', line 2

def initialize(agent, auth, *params)
  @agent = agent
  @auth = auth
  @params = params.first
  @stocks = []
end

Instance Method Details

#runObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/finviz_rails/screener.rb', line 9

def run
  @agent.get(url)
  set_pagination_count
  set_found_stock_count
  add_stocks_from_page(@agent.page.parser)
  if @pagination_count
    (2..@pagination_count).each do |page_num|
      break if max_stock_count && @stocks.count >= max_stock_count
      @agent.get url(page_num)
      add_stocks_from_page(@agent.page.parser)
    end
  end
  results
end