Class: Minpaso::SearchResultPager
- Inherits:
-
Object
- Object
- Minpaso::SearchResultPager
- Defined in:
- lib/minpaso.rb
Defined Under Namespace
Classes: Item
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
-
#initialize(doc, params) ⇒ SearchResultPager
constructor
A new instance of SearchResultPager.
-
#next ⇒ Object
Go to next page.
- #page ⇒ Object
-
#prev ⇒ Object
Go to previous page.
Constructor Details
#initialize(doc, params) ⇒ SearchResultPager
Returns a new instance of SearchResultPager.
86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/minpaso.rb', line 86 def initialize(doc, params) @params = params @items = [] doc.root.elements.each do |elt| case elt.name when "NumOfResult" @size = elt.text.to_i when "Item" @items << Item.new(elt) end end end |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
85 86 87 |
# File 'lib/minpaso.rb', line 85 def items @items end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
85 86 87 |
# File 'lib/minpaso.rb', line 85 def size @size end |
Instance Method Details
#next ⇒ Object
Go to next page.
111 112 113 114 115 |
# File 'lib/minpaso.rb', line 111 def next next_page = page + 1 return nil if next_page >= ((@size - 1) / 10) + 1 Minpaso.search(@params.merge(:p => next_page)) end |
#page ⇒ Object
99 100 101 |
# File 'lib/minpaso.rb', line 99 def page @params.has_key?("p") ? @params["p"] : 1 end |