Class: YouTubeIt::Parser::FeedParser

Inherits:
Object
  • Object
show all
Defined in:
lib/youtube_it/parser.rb

Overview

:nodoc:

Instance Method Summary collapse

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

#parseObject



14
15
16
# File 'lib/youtube_it/parser.rb', line 14

def parse
  parse_content @content
end

#parse_videosObject



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