Class: Amzwish::Wishlist::Page
- Inherits:
-
Object
- Object
- Amzwish::Wishlist::Page
- Defined in:
- lib/amzwish/wishlist.rb
Instance Method Summary collapse
- #books ⇒ Object
- #has_next? ⇒ Boolean
-
#initialize(html) ⇒ Page
constructor
A new instance of Page.
Constructor Details
#initialize(html) ⇒ Page
Returns a new instance of Page.
33 34 35 |
# File 'lib/amzwish/wishlist.rb', line 33 def initialize(html) @page = Nokogiri::HTML(html) end |
Instance Method Details
#books ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/amzwish/wishlist.rb', line 42 def books @page.xpath('//tbody[@class="itemWrapper"]').collect do |e| title = e.xpath('.//a[1]/text()').to_s asin = e.xpath("@name").to_s.split('.').last Book.new( title, asin) end end |
#has_next? ⇒ Boolean
37 38 39 40 |
# File 'lib/amzwish/wishlist.rb', line 37 def has_next? # look and see if the 'Next' at the end of the page is an active link @page.xpath('//div[@class="pagDiv"]/span[@class="pagSide"]/a/span/text()').any?{|t| t.to_s.include?("Next")} end |