Class Minpaso::SearchResultPager
In: lib/minpaso.rb
Parent: Object

Methods

new   next   page   prev  

Classes and Modules

Class Minpaso::SearchResultPager::Item

Attributes

items  [R] 
size  [R] 

Public Class methods

[Source]

    # File lib/minpaso.rb, line 86
86:     def initialize(doc, params)
87:       @params = params
88:       @items = []
89:       doc.root.elements.each do |elt|
90:         case elt.name
91:         when "NumOfResult"
92:           @size = elt.text.to_i
93:         when "Item"
94:           @items << Item.new(elt)
95:         end
96:       end
97:     end

Public Instance methods

Go to next page.

[Source]

     # File lib/minpaso.rb, line 111
111:     def next
112:       next_page = page + 1
113:       return nil if next_page >= ((@size - 1) / 10) + 1
114:       Minpaso.search(@params.merge(:p => next_page))
115:     end

[Source]

     # File lib/minpaso.rb, line 99
 99:     def page
100:       @params.has_key?("p") ? @params["p"] : 1
101:     end

Go to previous page.

[Source]

     # File lib/minpaso.rb, line 104
104:     def prev
105:       prev_page = page - 1
106:       return nil if prev_page <= 0
107:       Minpaso.search(@params.merge(:p => prev_page))
108:     end

[Validate]