Sha256: 312f322b30393c48e22d57cfb5e78092a5e55b9110725c5d4f5c09c151571653
Contents?: true
Size: 835 Bytes
Versions: 2
Compression:
Stored size: 835 Bytes
Contents
module CareerBuilder class Resume::LazyCollection attr_reader :search_options, :client def initialize(client, options) @client = client @search_options = options @current_page = @search_options[:page] || 1 end def each results = results_for @current_page loop do results.each do |resume| yield Resume.new(client, resume) end @current_page += 1 results = results_for @current_page break if results.empty? end end private def results_for(page) attempts = 0 search = client.advanced_resume_search(search_options.merge(:page_number => page, :rows_per_page => 500)) search.results rescue Errno::ECONNRESET => e attempts += 1 retry if attempts < 5 raise e end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
career_builder-0.2.2 | lib/career_builder/resume/lazy_collection.rb |
career_builder-0.2.1 | lib/career_builder/resume/lazy_collection.rb |