Module: Yahoo::SE::Paginator

Included in:
Inlinks, Pages
Defined in:
lib/yahoo-se/paginator.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



25
26
27
28
# File 'lib/yahoo-se/paginator.rb', line 25

def method_missing(method, *args)
  results
  response.send(method, *args)
end

Instance Method Details

#last?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/yahoo-se/paginator.rb', line 21

def last?
  (@options[:start] + @options[:results]) >= response.total_results_available
end

#nextObject

Reset the start option to the next results



11
12
13
14
15
# File 'lib/yahoo-se/paginator.rb', line 11

def next
  @options[:start] = @options[:start] + @options[:results]
  @options[:results] = total_results_available - @options[:start] if last?
  results
end

#responseObject

The response object from the request



5
6
7
8
# File 'lib/yahoo-se/paginator.rb', line 5

def response
  raise "Must send a request before you can get a response. Run the results method first!" if @request.nil?
  @response = @request.response
end

#total_results_availableObject



17
18
19
# File 'lib/yahoo-se/paginator.rb', line 17

def total_results_available
  @total_results_available ||= response.total_results_available
end