Module: Feedzirra::FeedEntryUtilities

Included in:
Parser::AtomEntry, Parser::AtomFeedBurnerEntry, Parser::RSSEntry
Defined in:
lib/feedzirra/feed_entry_utilities.rb

Instance Method Summary collapse

Instance Method Details

#idObject

Returns the id of the entry or its url if not id is present, as some formats don’t support it



18
19
20
# File 'lib/feedzirra/feed_entry_utilities.rb', line 18

def id
  @entry_id || @url
end

#parse_datetime(string) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/feedzirra/feed_entry_utilities.rb', line 7

def parse_datetime(string)
  begin
    DateTime.parse(string).feed_utils_to_gm_time
  rescue
    puts "DATE CAN'T BE PARSED: #{string}"
    nil
  end
end

#publishedObject Also known as: last_modified



3
4
5
# File 'lib/feedzirra/feed_entry_utilities.rb', line 3

def published
  @published || @updated
end

#published=(val) ⇒ Object

Writter for published. By default, we keep the “oldest” publish time found.



24
25
26
27
# File 'lib/feedzirra/feed_entry_utilities.rb', line 24

def published=(val)
  parsed = parse_datetime(val)
  @published = parsed if !@published || parsed < @published
end

#sanitize!Object



36
37
38
39
40
41
# File 'lib/feedzirra/feed_entry_utilities.rb', line 36

def sanitize!
  self.title.sanitize!   if self.title
  self.author.sanitize!  if self.author
  self.summary.sanitize! if self.summary
  self.content.sanitize! if self.content
end

#updated=(val) ⇒ Object

Writter for udapted. By default, we keep the most recenet update time found.



31
32
33
34
# File 'lib/feedzirra/feed_entry_utilities.rb', line 31

def updated=(val)
  parsed = parse_datetime(val)
  @updated = parsed if !@updated || parsed > @updated
end