Class: YouTubeIt::Parser::FeedParser
- Inherits:
-
Object
- Object
- YouTubeIt::Parser::FeedParser
- Defined in:
- lib/youtube_it/parser.rb
Overview
:nodoc:
Direct Known Subclasses
ActivityParser, CommentsFeedParser, ContactsParser, MessagesParser, PlaylistFeedParser, PlaylistsFeedParser, ProfileFeedParser, SubscriptionFeedParser, VideoFeedParser
Instance Method Summary collapse
-
#initialize(content) ⇒ FeedParser
constructor
A new instance of FeedParser.
- #parse ⇒ Object
- #parse_videos ⇒ Object
Constructor Details
#initialize(content) ⇒ FeedParser
Returns a new instance of FeedParser.
4 5 6 7 8 9 10 11 12 |
# File 'lib/youtube_it/parser.rb', line 4 def initialize(content) @content = (content =~ URI::regexp(%w(http https)) ? open(content).read : content) rescue OpenURI::HTTPError => e raise OpenURI::HTTPError.new(e.io.status[0],e) rescue @content = content end |
Instance Method Details
#parse ⇒ Object
14 15 16 |
# File 'lib/youtube_it/parser.rb', line 14 def parse parse_content @content end |
#parse_videos ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/youtube_it/parser.rb', line 18 def parse_videos doc = REXML::Document.new(@content) videos = [] doc.elements.each("*/entry") do |video| videos << parse_entry(video) end videos end |