Class: YouTubeIt::Parser::ContactsParser

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

Overview

Returns an array of the user’s contacts

Instance Method Summary collapse

Methods inherited from FeedParser

#initialize, #parse, #parse_single_entry, #parse_videos, #remove_bom

Constructor Details

This class inherits a constructor from YouTubeIt::Parser::FeedParser

Instance Method Details

#parse_content(content) ⇒ Object



251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# File 'lib/youtube_it/parser.rb', line 251

def parse_content(content)
  doc = Nokogiri::XML(content.body)
  feed = doc.at("feed")

  contacts = []
  feed.css("entry").each do |entry|
    temp_contact = YouTubeIt::Model::Contact.new(
      :title    => entry.at("title") ? entry.at("title").text : nil,
      :username => entry.at_xpath("yt:username") ? entry.at_xpath("yt:username").text : nil,
      :status   => entry.at_xpath("yt:status") ? entry.at_xpath("yt:status").text : nil
    )

    contacts << temp_contact
  end

  return contacts
end