Class: Goatless::OpmlFetcher
- Inherits:
-
Object
- Object
- Goatless::OpmlFetcher
- Defined in:
- lib/goatless/opml_fetcher.rb
Instance Attribute Summary collapse
-
#rss_urls ⇒ Object
Returns the value of attribute rss_urls.
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(username) ⇒ OpmlFetcher
constructor
A new instance of OpmlFetcher.
Constructor Details
#initialize(username) ⇒ OpmlFetcher
Returns a new instance of OpmlFetcher.
5 6 7 8 |
# File 'lib/goatless/opml_fetcher.rb', line 5 def initialize(username) @url = "http://www.livejournal.com/tools/opml.bml?user=#{username}" # @url = 'http://sdfgh153.ru/sample.opml' end |
Instance Attribute Details
#rss_urls ⇒ Object
Returns the value of attribute rss_urls.
3 4 5 |
# File 'lib/goatless/opml_fetcher.rb', line 3 def rss_urls @rss_urls end |
Instance Method Details
#fetch ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/goatless/opml_fetcher.rb', line 10 def fetch patron_session = Patron::Session.new patron_session.timeout = 30 patron_session.connect_timeout = 30000 @rss_urls = [] opml_doc = Nokogiri::XML(patron_session.get(@url).body) opml_doc.elements.xpath("//outline").each do |outline| @rss_urls << outline['xmlUrl'] end if Goatless.[:verbose] puts "You have #{@rss_urls.size} friends!" end @rss_urls end |