Skip to content

Instantly share code, notes, and snippets.

@HopperMCS
Created July 20, 2020 21:54
Show Gist options
  • Save HopperMCS/3b57c0544d10e2973e62bc9f284d1ffa to your computer and use it in GitHub Desktop.
Save HopperMCS/3b57c0544d10e2973e62bc9f284d1ffa to your computer and use it in GitHub Desktop.
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