Class: Alexa::UrlInfo::Related

Inherits:
Object
  • Object
show all
Includes:
Container
Defined in:
lib/alexa/url_info/related.rb

Instance Attribute Summary

Attributes included from Container

#data

Instance Method Summary collapse

Methods included from Container

included, #keys, #method_missing, #to_mongo

Constructor Details

#initialize(xml_node = nil) ⇒ Related

Returns a new instance of Related.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/alexa/url_info/related.rb', line 6

def initialize(xml_node = nil)
  @data = {}

  if !xml_node.nil?

    @data[:data_url] = xml_node.xpath('DataUrl').text.strip
    @data[:links]    = []

    xml_node.xpath('RelatedLinks/RelatedLink').each do |l|
      @data[:links] << {
        :data_url => l.xpath('DataUrl').text.strip,
        :navigable_url => l.xpath('NavigableUrl').text.strip,
        :title => l.xpath('Title').text.strip,
      }
    end
  end

end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Alexa::Container