Class: RSSable::Detection::FeedFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/rssable/detection/feed_finder.rb

Class Method Summary collapse

Class Method Details

.call(url:) ⇒ Array<String>

It returns array of RSS feed links for given URL

Returns:

  • (Array<String>)


7
8
9
10
11
12
13
14
15
16
# File 'lib/rssable/detection/feed_finder.rb', line 7

def self.call(url:)
  response = RestClient.get(url)
  html = Nokogiri::HTML(response.body)

  links = html.css("link[type='application/rss+xml']").map { |node| node[:href] }
  
  return links if links.size > 0

  url.end_with?('/') ? ["#{url}feed/"] : ["#{url}/feed/"]
end