module Feedjira::FeedEntryUtilities

Public Instance Methods

[](field) click to toggle source
# File lib/feedjira/feed_entry_utilities.rb, line 57
def [](field)
  self.instance_variable_get("@#{field.to_s}")
end
[]=(field, value) click to toggle source
# File lib/feedjira/feed_entry_utilities.rb, line 61
def []=(field, value)
  self.instance_variable_set("@#{field.to_s}", value)
end
each() { |field.sub('@', ''), instance_variable_get| ... } click to toggle source
# File lib/feedjira/feed_entry_utilities.rb, line 49
def each
  @rss_fields ||= self.instance_variables

  @rss_fields.each do |field|
    yield(field.to_s.sub('@', ''), self.instance_variable_get(field))
  end
end
id() click to toggle source

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

# File lib/feedjira/feed_entry_utilities.rb, line 21
def id
  @entry_id ||= @url
end
last_modified()
Alias for: published
parse_datetime(string) click to toggle source
# File lib/feedjira/feed_entry_utilities.rb, line 10
def parse_datetime(string)
  begin
    DateTime.parse(string).feed_utils_to_gm_time
  rescue
    warn "Failed to parse date #{string.inspect}"
    nil
  end
end
published() click to toggle source
# File lib/feedjira/feed_entry_utilities.rb, line 6
def published
  @published ||= @updated
end
Also aliased as: last_modified
published=(val) click to toggle source

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

# File lib/feedjira/feed_entry_utilities.rb, line 27
def published=(val)
  parsed = parse_datetime(val)
  @published = parsed if !@published || parsed < @published
end
sanitize!() click to toggle source
# File lib/feedjira/feed_entry_utilities.rb, line 39
def sanitize!
  %w[title author summary content image].each do |name|
    if self.respond_to?(name) && self.send(name).respond_to?(:sanitize!)
      self.send(name).send :sanitize!
    end
  end
end
updated=(val) click to toggle source

Writer for updated. By default, we keep the most recent update time found.

# File lib/feedjira/feed_entry_utilities.rb, line 34
def updated=(val)
  parsed = parse_datetime(val)
  @updated = parsed if !@updated || parsed > @updated
end