Class: RssParser
- Inherits:
-
Object
- Object
- RssParser
- Defined in:
- lib/rss_parser.rb
Instance Attribute Summary collapse
-
#feed ⇒ Object
Returns the value of attribute feed.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(url, user, password) ⇒ RssParser
constructor
A new instance of RssParser.
- #process ⇒ Object
Constructor Details
#initialize(url, user, password) ⇒ RssParser
Returns a new instance of RssParser.
33 34 35 36 37 |
# File 'lib/rss_parser.rb', line 33 def initialize(url, user, password) @url = URI.parse(url) @user = user @password = password end |
Instance Attribute Details
#feed ⇒ Object
Returns the value of attribute feed.
25 26 27 |
# File 'lib/rss_parser.rb', line 25 def feed @feed end |
Class Method Details
.parse(url, user = nil, password = nil) ⇒ Object
27 28 29 30 31 |
# File 'lib/rss_parser.rb', line 27 def self.parse(url, user = nil, password = nil) rss = new(url, user, password) rss.process rss.feed end |
Instance Method Details
#process ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rss_parser.rb', line 39 def process Net::HTTP.start(@url.host, @url.port) do |http| # FIXME (Did): handle url like "http://www.example.com/?feed=rss2" used by Wordpress for instance path = @url.path path << "?#{@url.query}" if @url.query data = get_data(http, prepare_request(path)) @feed = parse(data) end end |