Class: FeedDiscover
- Inherits:
-
Object
- Object
- FeedDiscover
- Defined in:
- lib/feed_discover.rb
Overview
This class performs feed autodiscovery. This is is the process of determining the Atom/RSS URL(s) for a given X?HTML page.
Sample Usage
require ‘rubygems’ require ‘feed_discover’ fd = FeedDiscover.new(‘bbc.co.uk/’) if fd.feeds?
puts fd.feeds.join("\n")
else
puts "No feeds found"
end
Or:
require ‘rubygems’ require ‘feed_discover’ puts FeedDiscover.new(‘inelegant.org/’).feed
Instance Method Summary collapse
-
#feed ⇒ Object
Returns the absolute URL of the first feed found as a string.
-
#feeds ⇒ Object
Returns an array of absolute feed URLs which were discovered.
-
#feeds? ⇒ Boolean
Returns true if feeds were found; false if not.
-
#initialize(url) ⇒ FeedDiscover
constructor
The class should be initialized with the URL of the page to perform autodiscovery on.
Constructor Details
#initialize(url) ⇒ FeedDiscover
The class should be initialized with the URL of the page to perform autodiscovery on. The URL should be absolute and use either the HTTP or HTTP protocol scheme. The URL should be a string or an object whose to_s
method returns a string. An exception will be raised if the URL has invalid syntax.
72 73 74 75 76 |
# File 'lib/feed_discover.rb', line 72 def initialize(url) @url = URI.parse(url.to_s) @feeds = [] autodiscover end |
Instance Method Details
#feed ⇒ Object
Returns the absolute URL of the first feed found as a string
85 86 87 |
# File 'lib/feed_discover.rb', line 85 def feed @feeds[0] end |
#feeds ⇒ Object
Returns an array of absolute feed URLs which were discovered. If no feeds were found, an empty array is returned.
80 81 82 |
# File 'lib/feed_discover.rb', line 80 def feeds @feeds || [] end |
#feeds? ⇒ Boolean
Returns true if feeds were found; false if not
90 91 92 |
# File 'lib/feed_discover.rb', line 90 def feeds? !feeds.empty? end |