class RarchNews::Article

Attributes

creator[RW]
description[RW]
pub_date[RW]
title[RW]

Public Class Methods

last_article() click to toggle source
# File lib/rarch_news/article.rb, line 33
def self.last_article
    # return nil unless File.exist? File.join(RarchNews.configuration.path,RarchNews.configuration.name)
    return nil if RarchNews.first_run? # TODO raise something
    YAML.load_file(File.join(RarchNews.configuration.path, RarchNews.configuration.last_article))
end
new(title, link, description, creator, pub_date) click to toggle source
# File lib/rarch_news/article.rb, line 9
def initialize(title, link, description, creator, pub_date)
    # def initialize(title, link, description, creator, pub_date,*options)
    # raise "Unexpected arguments" unless options.length == 4 or options.length == 0
    @title = title
    @link = link
    @description = description
    @creator = creator
    @pub_date = Date.archdate pub_date # unless pub_date.is_a? DateTime
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/rarch_news/article.rb, line 23
def <=>(other)
    @pub_date <=> other.pub_date
end
save!() click to toggle source
# File lib/rarch_news/article.rb, line 27
def save!
    File.open File.join(RarchNews.configuration.path, RarchNews.configuration.last_article), 'w' do |file|
        file.puts YAML.dump self
    end
end
to_s() click to toggle source
# File lib/rarch_news/article.rb, line 19
def to_s
    "#{@title} <By: #{@creator}. At: #{@pub_date}>\n#{@link}\n#{@description}"
end