Sha256: 676f1eac9142f4ba7eec92d387291883c0169985d5458d05279f1f87cadf1a27

Contents?: true

Size: 808 Bytes

Versions: 2

Compression:

Stored size: 808 Bytes

Contents

module ARBookFinder
  class Scraper
    def initialize(user_type)
      UserTypeProcessor.new(user_type).process
    end

    def search(query, page = 1)
      QuickSearchProcessor.new(query).process
      results = SearchResultsParser.new(Capybara.page.html).parse
      if page > 1
        results = paginate(page, false)
      end
      results
    end
    
    def collection(collection, page = 1)
      CollectionProcessor.new(collection).process
      results = SearchResultsParser.new(Capybara.page.html, true).parse
      if page > 1
        results = paginate(page, true)
      end
      results
    end
    
    private
    def paginate(page, collection) 
      PaginationProcessor.new(page, collection).process
      SearchResultsParser.new(Capybara.page.html, collection).parse
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ar_book_finder-1.1.1 lib/ar_book_finder/scraper.rb
ar_book_finder-1.1.0 lib/ar_book_finder/scraper.rb