class DeveloperNewsCliApp::AListApartScrapper

Public Class Methods

article_count() click to toggle source
# File lib/developer_news_cli_app/AListApartScrapper.rb, line 28
def self.article_count
        @@all.count
end
articles() click to toggle source
# File lib/developer_news_cli_app/AListApartScrapper.rb, line 24
def self.articles
        @@all
end

Public Instance Methods

get_articles() click to toggle source
# File lib/developer_news_cli_app/AListApartScrapper.rb, line 8
def get_articles
        self.get_page.css(".entry-list")
end
get_page() click to toggle source
# File lib/developer_news_cli_app/AListApartScrapper.rb, line 4
def get_page
        Nokogiri::HTML(open("https://alistapart.com/articles"))
end
make_article() click to toggle source
# File lib/developer_news_cli_app/AListApartScrapper.rb, line 12
def make_article
        self.get_articles.each do |article|
                a = DeveloperNewsCliApp::Article.new
                a.title = article.css(".entry-title a").text
                a.author = article.css(".author").text
                a.date = article.css("time").text
                a.trailing = article.css("p")[1].text
                a.url = "https://alistapart.com" + article.css(".entry-title a").attribute("href").value
                @@all << a
        end
end