Class: CareerBuilder::Resume::LazyCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/career_builder/resume/lazy_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, options) ⇒ LazyCollection

Returns a new instance of LazyCollection.



7
8
9
10
11
# File 'lib/career_builder/resume/lazy_collection.rb', line 7

def initialize(client, options)
  @client = client
  @search_options = options
  @current_page = @search_options[:page] || 1
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



5
6
7
# File 'lib/career_builder/resume/lazy_collection.rb', line 5

def client
  @client
end

#search_optionsObject (readonly)

Returns the value of attribute search_options.



5
6
7
# File 'lib/career_builder/resume/lazy_collection.rb', line 5

def search_options
  @search_options
end

Instance Method Details

#eachObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/career_builder/resume/lazy_collection.rb', line 13

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