Class: RssFeed::Feed::Channel

Inherits:
Base show all
Defined in:
lib/rss_feed/feed/channel.rb

Overview

The Channel class represents a channel in an RSS feed.

Constant Summary collapse

TAGS =

List of commonly used tags in an RSS channel.

%w[
  id
  title subtitle link
  description
  author webMaster managingEditor contributor
  pubDate lastBuildDate updated dc:date
  generator language docs cloud
  ttl skipHours skipDays
  image logo icon rating
  rights copyright
  textInput feedburner:browserFriendly
  itunes:author itunes:category category itunes:explicit itunes:image itunes:keywords itunes:owner itunes:subtitle
  itunes:summary
].freeze

Instance Attribute Summary

Attributes inherited from Base

#document

Instance Method Summary collapse

Methods inherited from Base

#detect_feed_type, #execute_method, #initialize, #parser

Constructor Details

This class inherits a constructor from RssFeed::Feed::Base

Instance Method Details

#atom ⇒ Object Also known as: feed

XPath expression for selecting the Atom feed.



32
33
34
35
36
# File 'lib/rss_feed/feed/channel.rb', line 32

def atom
  return nil if document.blank?

  '//xmlns:feed'
end

#parse ⇒ Nokogiri::XML::NodeSet?

Parses the RSS channel or Atom feed based on the detected feed type.

Returns:

  • (Nokogiri::XML::NodeSet, nil) —

    The parsed channel or feed, or nil if not found.



43
44
45
# File 'lib/rss_feed/feed/channel.rb', line 43

def parse
  document.xpath(execute_method)
end

#rss ⇒ Object

XPath expression for selecting the RSS channel.



25
26
27
28
29
# File 'lib/rss_feed/feed/channel.rb', line 25

def rss
  return nil if document.blank?

  '//channel'
end