Module: Feedzirra::FeedEntryUtilities
- Included in:
- Parser::AtomEntry, Parser::AtomFeedBurnerEntry, Parser::ITunesRSSItem, Parser::RSSEntry
- Defined in:
- lib/feedzirra/feed_entry_utilities.rb
Instance Method Summary collapse
-
#id ⇒ Object
Returns the id of the entry or its url if not id is present, as some formats don’t support it.
- #parse_datetime(string) ⇒ Object
- #published ⇒ Object (also: #last_modified)
-
#published=(val) ⇒ Object
Writer for published.
- #sanitize! ⇒ Object
-
#updated=(val) ⇒ Object
Writer for updated.
Instance Method Details
#id ⇒ Object
Returns the id of the entry or its url if not id is present, as some formats don’t support it
19 20 21 |
# File 'lib/feedzirra/feed_entry_utilities.rb', line 19 def id @entry_id ||= @url end |
#parse_datetime(string) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/feedzirra/feed_entry_utilities.rb', line 8 def parse_datetime(string) begin DateTime.parse(string).feed_utils_to_gm_time rescue puts "DATE CAN'T BE PARSED: [#{string}]" nil end end |
#published ⇒ Object Also known as: last_modified
4 5 6 |
# File 'lib/feedzirra/feed_entry_utilities.rb', line 4 def published @published ||= @updated end |
#published=(val) ⇒ Object
Writer for published. By default, we keep the “oldest” publish time found.
25 26 27 28 |
# File 'lib/feedzirra/feed_entry_utilities.rb', line 25 def published=(val) parsed = parse_datetime(val) @published = parsed if !@published || parsed < @published end |
#sanitize! ⇒ Object
37 38 39 40 41 42 |
# File 'lib/feedzirra/feed_entry_utilities.rb', line 37 def sanitize! self.title.sanitize! if self.title self..sanitize! if self. self.summary.sanitize! if self.summary self.content.sanitize! if self.content end |
#updated=(val) ⇒ Object
Writer for updated. By default, we keep the most recent update time found.
32 33 34 35 |
# File 'lib/feedzirra/feed_entry_utilities.rb', line 32 def updated=(val) parsed = parse_datetime(val) @updated = parsed if !@updated || parsed > @updated end |