Class: GoApiClient::Parsers::Feed

Inherits:
Helper
  • Object
show all
Defined in:
lib/go_api_client/parsers/feed_parser.rb

Class Method Summary collapse

Methods inherited from Helper

href_from

Class Method Details

.parse(root) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/go_api_client/parsers/feed_parser.rb', line 7

def parse(root)
  GoApiClient::Domain::Feed.new(
      {
          :title => root.xpath('xmlns:title').first.content,
          :id => root.xpath('xmlns:id').first.content,
          :self_uri => href_from(root.xpath("xmlns:link[@rel='self']")),
          :next_uri => href_from(root.xpath("xmlns:link[@rel='next']")),
          :updated => Time.parse(root.xpath('xmlns:updated').first.content).utc,
          :parsed_authors => root.xpath('xmlns:author').collect do |element|
            GoApiClient::Parsers::Author.parse(element)
          end,
          :parsed_entries => root.xpath('xmlns:entry').collect do |element|
            GoApiClient::Parsers::Entry.parse(element)
          end
      })
end