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_videos

Constructor Details

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

Instance Method Details

#parse_content(content) ⇒ Object



253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/youtube_it/parser.rb', line 253

def parse_content(content)
  doc = REXML::Document.new(content.body)
  puts content.body
  puts "doc..."
  puts doc.inspect
  feed = doc.elements["feed"]
  
  messages = []
  feed.elements.each("entry") do |entry|
    author = entry.elements["author"]
    temp_message = YouTubeIt::Model::Message.new(
      :id  => entry.elements["id"] ? entry.elements["id"].text.gsub(/.+:inbox:/, "") : nil, 
      :title    => entry.elements["title"] ? entry.elements["title"].text : nil,
      :name => author && author.elements["name"] ? author.elements["name"].text : nil,
      :summary   => entry.elements["summary"] ? entry.elements["summary"].text : nil,
      :published   => entry.elements["published"] ? entry.elements["published"].text : nil
    )
    
    messages << temp_message
  end
  
  return messages
end