class DeveloperNewsCliApp::HackerNoonScrapper
Public Class Methods
article_count()
click to toggle source
# File lib/developer_news_cli_app/HackerNoonScrapper.rb, line 29 def self.article_count @@all.count end
articles()
click to toggle source
# File lib/developer_news_cli_app/HackerNoonScrapper.rb, line 25 def self.articles @@all end
Public Instance Methods
get_articles()
click to toggle source
# File lib/developer_news_cli_app/HackerNoonScrapper.rb, line 8 def get_articles self.get_page.css(".js-trackedPost") end
get_page()
click to toggle source
# File lib/developer_news_cli_app/HackerNoonScrapper.rb, line 4 def get_page Nokogiri::HTML(open("https://hackernoon.com/")) end
make_article()
click to toggle source
# File lib/developer_news_cli_app/HackerNoonScrapper.rb, line 12 def make_article self.get_articles.each do |article| a = DeveloperNewsCliApp::Article.new a.title = article.css("h3").text a.author = article.css(".ds-link").text a.date = article.css("time").text a.url = article.css("a").attribute("href").value a.website = "HackerNoon" a.trailing = article.css(".u-fontSize18").text == "" ? nil : article.css(".u-fontSize18").text @@all << a end end