Created
September 5, 2012 07:29
-
-
Save Jarred-Sumner/3632622 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 Status < ActiveRecord::Base | |
belongs_to :feed | |
attr_accessible :description, :publication_date, :title | |
attr_protected :feed_id | |
def self.update_or_create_with_entry(entry, feed_id) | |
if entry.present? | |
if @@status = Status.find_by_publication_date(entry.published.to_datetime) | |
@@status.update_status!(entry) | |
else | |
Status.parse_status(entry, feed_id) | |
end | |
end | |
end | |
def self.parse_status(entry, feed_id) | |
@@status = Status.new | |
@@status.title = entry.title unless entry.title.class.to_s == "Fixnum" | |
@@status.publication_date = entry.published.to_datetime | |
@@status.feed_id = feed_id | |
@@status.description = entry.summary | |
@@status.save! | |
puts "Created status!" | |
end | |
def update_status!(entry) | |
self.description = entry.summary | |
self.title = entry.title | |
self.publication_date = entry.published.to_datetime | |
self.save! | |
puts "Updated status!" | |
end | |
def bad? | |
if title.include? "[Resolved]" or title.include? "[RESOLVED]" or title.include? "normally" then | |
return false | |
else | |
return true | |
end | |
end | |
def good? | |
!bad? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment