Class: NewsScraper::Trainer::UrlTrainer
- Inherits:
-
Object
- Object
- NewsScraper::Trainer::UrlTrainer
- Defined in:
- lib/news_scraper/trainer/url_trainer.rb
Instance Method Summary collapse
-
#initialize(url) ⇒ UrlTrainer
constructor
A new instance of UrlTrainer.
- #train ⇒ Object
Constructor Details
#initialize(url) ⇒ UrlTrainer
Returns a new instance of UrlTrainer.
4 5 6 7 8 |
# File 'lib/news_scraper/trainer/url_trainer.rb', line 4 def initialize(url) @url = url @root_domain = URIParser.new(@url).host @payload = Extractors::Article.new(url: @url).extract end |
Instance Method Details
#train ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/news_scraper/trainer/url_trainer.rb', line 10 def train return if NewsScraper.configuration.scrape_patterns['domains'].key?(@root_domain) CLI.put_header(@root_domain) CLI.log("There is no scrape pattern defined for #{@root_domain}") CLI.log "Fetching information..." CLI. selected_presets = {} NewsScraper.configuration.scrape_patterns['data_types'].each do |data_type| selected_presets[data_type] = selected_pattern(data_type) end save_selected_presets(selected_presets) end |