class Article

> Handles Article object creation

Attributes

author[RW]

> Accessors for article details

body[RW]

> Accessors for article details

date[RW]

> Accessors for article details

excerpt[RW]

> Accessors for article details

title[RW]

> Accessors for article details

type[RW]

> Accessors for article details

Public Class Methods

all() click to toggle source

> Getter returns all of our article objects

# File lib/crowder_news/article.rb, line 50
def self.all
  @@all;
end
create_from_collection(articles_array) click to toggle source

> Creates articles from a hash of article information

# File lib/crowder_news/article.rb, line 33
def self.create_from_collection(articles_array)
  articles_array.each { |hash|
    self.new(hash)
  }
end
new(article_hash) click to toggle source

> Creates new Article objects

# File lib/crowder_news/article.rb, line 16
def initialize(article_hash)
  @title = article_hash[:title]
  @link = article_hash[:link]
  @excerpt = article_hash[:excerpt]
  @type = article_hash[:type]

  if @type.downcase == "recent"
    @@recents << self
  elsif @type.downcase == "featured"
    @@featured << self
  end
  @@all << self;
end
recents() click to toggle source

> Getter returns all of our recent articles

# File lib/crowder_news/article.rb, line 55
def self.recents
  @@recents
end

Public Instance Methods

add_details(details_hash) click to toggle source

> Adds the additional details to our Article object

# File lib/crowder_news/article.rb, line 42
def add_details(details_hash)
  @author = details_hash[:author]
  @date = details_hash[:date]
  @body = details_hash[:body]
  @youtube_links = details_hash[:youtube_links]
end