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_videos

Constructor Details

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

Instance Method Details

#parse_content(content) ⇒ Object



232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/youtube_it/parser.rb', line 232

def parse_content(content)
  doc = REXML::Document.new(content.body)
  feed = doc.elements["feed"]
  
  contacts = []
  feed.elements.each("entry") do |entry|
    temp_contact = YouTubeIt::Model::Contact.new(
      :title    => entry.elements["title"] ? entry.elements["title"].text : nil,
      :username => entry.elements["yt:username"] ? entry.elements["yt:username"].text : nil,
      :status   => entry.elements["yt:status"] ? entry.elements["yt:status"].text : nil
    )
    
    contacts << temp_contact
  end
  
  return contacts
end