Class: Googletastic::Head

Inherits:
Base
  • Object
show all
Defined in:
lib/googletastic/head.rb

Constant Summary

Constants included from Mixins::Namespaces

Mixins::Namespaces::NAMESPACES

Instance Attribute Summary collapse

Attributes inherited from Base

#acl, #attachment_path, #created_at, #etag, #head, #id, #keep_raw, #raw, #response, #synced_with, #updated_at

Attributes included from Mixins::Attributes

#attributes

Class Method Summary collapse

Methods inherited from Base

client_class, #initialize, #to_xml

Methods included from Mixins::Pagination

included

Methods included from Mixins::Finders

included

Methods included from Mixins::Parsing

included

Methods included from Mixins::Requesting

included

Methods included from Mixins::Attributes

#attribute_names, #has_attribute?, #inspect

Methods included from Mixins::Namespaces

included

Constructor Details

This class inherits a constructor from Googletastic::Base

Instance Attribute Details

#per_pageObject

Returns the value of attribute per_page.



3
4
5
# File 'lib/googletastic/head.rb', line 3

def per_page
  @per_page
end

#start_indexObject

Returns the value of attribute start_index.



3
4
5
# File 'lib/googletastic/head.rb', line 3

def start_index
  @start_index
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/googletastic/head.rb', line 3

def title
  @title
end

#total_resultsObject

Returns the value of attribute total_results.



3
4
5
# File 'lib/googletastic/head.rb', line 3

def total_results
  @total_results
end

Class Method Details

.unmarshall(xml) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/googletastic/head.rb', line 7

def unmarshall(xml)
  feed          = xml.xpath("atom:feed", ns_tag("atom")).first
  return nil unless feed

  id            = feed.xpath("atom:id", ns_tag("atom")).text
  updated_at    = feed.xpath("atom:updated", ns_tag("atom")).text
  title         = feed.xpath("atom:title", ns_tag("atom")).text
  total_results = feed.xpath("openSearch:totalResults", ns_tag("openSearch")).text
  start_index   = feed.xpath("openSearch:startIndex", ns_tag("openSearch")).text
  per_page      = feed.xpath("openSearch:itemsPerPage", ns_tag("openSearch")).text
  
  head = Googletastic::Head.new(
    :id => id,
    :title => title,
    :updated_at => DateTime.parse(updated_at),
    :total_results => total_results,
    :start_index => start_index,
    :per_page => per_page
  )
end