Class: Tubeclip::Parser::ContactsParser

Inherits:
FeedParser
  • Object
show all
Defined in:
lib/tubeclip/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 Tubeclip::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/tubeclip/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 = Tubeclip::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