Class: CollegiateLink::Response::XML

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/collegiatelink/response.rb

Overview

Container for the XML gunk returned from CollegiateLink

Instance Method Summary collapse

Methods included from Common

#has_next_page?

Constructor Details

#initialize(document) ⇒ XML

Create the response.

Parameters:

  • document - The Nokogiri document of the returned XML

Raises:



20
21
22
23
24
25
26
27
28
# File 'lib/collegiatelink/response.rb', line 20

def initialize(document)
  raise UnknownException unless document.xpath('//results/page')

  @document = document
  @page_size   = document.xpath('//results/page/pageSize').inner_html.to_i
  @page_number = document.xpath('//results/page/pageNumber').inner_html.to_i
  @total_items = document.xpath('//results/page/totalItems').inner_html.to_i
  @total_pages = document.xpath('//results/page/totalPages').inner_html.to_i
end

Instance Method Details

#itemsObject

Extract the items from the response. Returns a Nokogiri NodeSet.



31
32
33
# File 'lib/collegiatelink/response.rb', line 31

def items
  @document.xpath('//results/page/items/*')
end