Class: YouTubeIt::Parser::MessagesParser

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

Overview

Returns an array of the user’s messages

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



272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# File 'lib/youtube_it/parser.rb', line 272

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

  messages = []
  feed.css("entry").each do |entry|
    author = entry.at("author")
    temp_message = YouTubeIt::Model::Message.new(
      :id  => entry.at("id") ? entry.at("id").text.gsub(/.+:inbox:/, "") : nil,
      :title    => entry.at("title") ? entry.at("title").text : nil,
      :name => author && author.at("name") ? author.at("name").text : nil,
      :summary   => entry.at("summary") ? entry.at("summary").text : nil,
      :published   => entry.at("published") ? entry.at("published").text : nil
    )

    messages << temp_message
  end

  return messages
end