Module: Feedract

Defined in:
lib/feedract.rb,
lib/feedract/version.rb

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.load(url_string) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/feedract.rb', line 9

def self.load(url_string)
  feed = []
  url = URI(url_string)
  Nokogiri::HTML(open(url).read).css("link").each do |link|
    if link["type"] == 'application/rss+xml' && link['rel'] == 'alternate'
      feed << (url + link['href']).to_s
    elsif link["type"] == 'application/atom+xml' && link['rel'] == 'alternate'
      feed << (url + link['href']).to_s
    end
  end
  feed
end