Class: NprCliNewsReader::Article
- Inherits:
-
Object
- Object
- NprCliNewsReader::Article
- Defined in:
- lib/npr_cli_news_reader/article.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#article_url ⇒ Object
Returns the value of attribute article_url.
-
#author ⇒ Object
Returns the value of attribute author.
-
#category ⇒ Object
Returns the value of attribute category.
-
#date ⇒ Object
Returns the value of attribute date.
-
#full_article ⇒ Object
Returns the value of attribute full_article.
-
#teaser ⇒ Object
Returns the value of attribute teaser.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
- #add_full_article(full_article) ⇒ Object
-
#initialize(article_attributes) ⇒ Article
constructor
A new instance of Article.
Constructor Details
#initialize(article_attributes) ⇒ Article
Returns a new instance of Article.
7 8 9 10 |
# File 'lib/npr_cli_news_reader/article.rb', line 7 def initialize(article_attributes) article_attributes.each { |k, v| self.send("#{k}=", v.strip) } @@all << self end |
Instance Attribute Details
#article_url ⇒ Object
Returns the value of attribute article_url.
3 4 5 |
# File 'lib/npr_cli_news_reader/article.rb', line 3 def article_url @article_url end |
#author ⇒ Object
Returns the value of attribute author.
3 4 5 |
# File 'lib/npr_cli_news_reader/article.rb', line 3 def @author end |
#category ⇒ Object
Returns the value of attribute category.
3 4 5 |
# File 'lib/npr_cli_news_reader/article.rb', line 3 def category @category end |
#date ⇒ Object
Returns the value of attribute date.
3 4 5 |
# File 'lib/npr_cli_news_reader/article.rb', line 3 def date @date end |
#full_article ⇒ Object
Returns the value of attribute full_article.
3 4 5 |
# File 'lib/npr_cli_news_reader/article.rb', line 3 def full_article @full_article end |
#teaser ⇒ Object
Returns the value of attribute teaser.
3 4 5 |
# File 'lib/npr_cli_news_reader/article.rb', line 3 def @teaser end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/npr_cli_news_reader/article.rb', line 3 def title @title end |
Class Method Details
.all ⇒ Object
12 13 14 |
# File 'lib/npr_cli_news_reader/article.rb', line 12 def self.all @@all end |
.sort_articles_by_category(filter) ⇒ Object
20 21 22 |
# File 'lib/npr_cli_news_reader/article.rb', line 20 def self.sort_articles_by_category(filter) self.all.select {|article| article.category == filter.downcase} end |
Instance Method Details
#add_full_article(full_article) ⇒ Object
16 17 18 |
# File 'lib/npr_cli_news_reader/article.rb', line 16 def add_full_article(full_article) self.full_article = full_article end |