Class: AtomFeed::OpenSearch

Inherits:
Object show all
Defined in:
lib/atom_feed/open_search.rb

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ OpenSearch

Initializes the Open Search extensions.



6
7
8
# File 'lib/atom_feed/open_search.rb', line 6

def initialize(node)
  @node = node
end

Instance Method Details

#items_per_pageObject

def start_page

  @node.at_xpath("atom:feed/opensearch:startPage", ::AtomFeed::NS).content.to_i rescue nil
end


28
29
30
# File 'lib/atom_feed/open_search.rb', line 28

def items_per_page
  @node.at_xpath("atom:feed/opensearch:itemsPerPage", ::AtomFeed::NS).content.to_i rescue nil
end

#present?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/atom_feed/open_search.rb', line 10

def present?
  !self.total_results.nil?
end

#queriesObject

queries



33
34
35
36
# File 'lib/atom_feed/open_search.rb', line 33

def queries
  nodes = @node.xpath("atom:feed/opensearch:Query", ::AtomFeed::NS) rescue nil
  nodes.map { |node| OpenSearchQuery.new(node) } if nodes
end

#start_indexObject



18
19
20
# File 'lib/atom_feed/open_search.rb', line 18

def start_index
  @node.at_xpath("atom:feed/opensearch:startIndex", ::AtomFeed::NS).content.to_i rescue nil
end

#total_resultsObject



14
15
16
# File 'lib/atom_feed/open_search.rb', line 14

def total_results
  @node.at_xpath("atom:feed/opensearch:totalResults", ::AtomFeed::NS).content.to_i rescue nil
end