Created
July 20, 2020 21:54
-
-
Save HopperMCS/3b57c0544d10e2973e62bc9f284d1ffa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Article | |
attr_accessor :title, :description, :url | |
@@all = [] | |
def initialize(attributes) | |
@title = attributes["title"] | |
@description = attributes["description"] | |
@url = attributes["url"] | |
end | |
def self.search(query) | |
@@all = API.get_headlines(query).map do |article_hash| | |
self.new(article_hash) | |
end | |
end | |
def self.clear | |
@@all.clear | |
end | |
def self.all | |
@@all | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment