Class: Finviz::TickersFetcher
- Inherits:
-
Object
- Object
- Finviz::TickersFetcher
- Defined in:
- lib/finviz/tickers_fetcher.rb
Overview
Fetch the list of tickers basing on the provided uri or array of filters
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(uri: nil, filters: [], **rest) ⇒ TickersFetcher
constructor
A new instance of TickersFetcher.
Constructor Details
#initialize(uri: nil, filters: [], **rest) ⇒ TickersFetcher
Returns a new instance of TickersFetcher.
8 9 10 11 12 13 |
# File 'lib/finviz/tickers_fetcher.rb', line 8 def initialize(uri: nil, filters: [], **rest) raise("You should provide either uri or filters") if uri.present? && filters.present? raise("Do not support option #{rest.keys}") unless rest.empty? normalize_uri(uri, filters) end |
Instance Attribute Details
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
6 7 8 |
# File 'lib/finviz/tickers_fetcher.rb', line 6 def uri @uri end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/finviz/tickers_fetcher.rb', line 15 def call all_pages = first_page + remaining_pages all_pages .map { |p| p.html.css("table span[onclick]") } .flatten .map { |a| a.children.text.gsub(/[[:space:]]+/, "") } end |