class GScraper::Search::Page

Public Instance Methods

cached_pages() click to toggle source

Returns the Cached Pages of the results in the page.

@return [Array<Mechanize::Page>]

The Cached Pages of the results.
# File lib/gscraper/search/page.rb, line 351
def cached_pages
  each_cached_page.to_a
end
cached_pages_of(&block) click to toggle source

Returns the cached pages of the results that match the given block.

@yield [result]

The given block will be used to filter the results in the page.

@yieldparam [Result] result

A result in the page.

@return [Array<Mechanize::Page>]

The Cached Page of the results which match the given block.

@example

page.cached_pages_of { |result| result.title =~ /dude/ }
# File lib/gscraper/search/page.rb, line 475
def cached_pages_of(&block)
  results_with(&block).cached_pages
end
cached_urls() click to toggle source

Returns the Cached URLs of the results in the page.

@return [Array<URI::HTTP>]

The Cached URLs of the results.
# File lib/gscraper/search/page.rb, line 341
def cached_urls
  each_cached_url.to_a
end
cached_urls_of(&block) click to toggle source

Returns the Cached URLs of the results that match the given block.

@yield [result]

The given block will be used to filter the results in the page.

@yieldparam [Result] result

A result in the page.

@return [Array<URI::HTTP>]

The Cached URLs of the results which match the given block.

@example

page.cached_urls_of { |result| result.title =~ /howdy/ }
# File lib/gscraper/search/page.rb, line 456
def cached_urls_of(&block)
  results_with(&block).cached_urls
end
each_cached_page() { |cached_page| ... } click to toggle source

Iterates over each result’s cached pages within the page.

@yield [cached_page]

The given block will be passed the Cached Page of each result in
the page.

@yieldparam [Mechanize::Page] cached_page

The Cached Page of a result in the page.

@return [Enumerator]

If no block is given, an Enumerator object will be returned.

@example

each_cached_page { |page| puts page.readlines }
# File lib/gscraper/search/page.rb, line 263
def each_cached_page
  return enum_for(:each_cached_page) unless block_given?

  each do |result|
    yield result.cached_page if result.cached_page
  end
end
each_cached_url() { |cached_url| ... } click to toggle source

Iterates over each result’s cached URLs within the page.

@yield [cached_url]

The given block will be passed the Cached URL of each result in
the page.

@yieldparam [URI::HTTP] cached_url

The Cached URL of a result in the page.

@return [Enumerator]

If no block is given, an Enumerator object will be returned.

@example

each_cached_url { |cached_url| puts cached_url }
# File lib/gscraper/search/page.rb, line 239
def each_cached_url
  return enum_for(:each_cached_url) unless block_given?

  each do |result|
    yield result.cached_url if result.cached_url
  end
end
each_rank() { |rank| ... } click to toggle source

Iterates over each result’s rank within the page.

@yield [rank]

The given block will be passed the ranks of each result in
the page.

@yieldparam [Integer] rank

The rank of a result in the page.

@return [Enumerator]

If no block is given, an Enumerator object will be returned.

@example

each_rank { |rank| puts rank }
# File lib/gscraper/search/page.rb, line 151
def each_rank
  return enum_for(:each_rank) unless block_given?

  each { |result| yield result.rank }
end
each_similar_url() { |similar_url| ... } click to toggle source

Iterates over each result’s similar Query URLs within the page.

@yield [similar_url]

The given block will be passed the Similar Query URL of each
result in the page.

@yieldparam [URI::HTTP] similar_url

The Cached URL of a result in the page.

@return [Enumerator]

If no block is given, an Enumerator object will be returned.

@example

each_similar_url { |similar_url| puts similar_url }
# File lib/gscraper/search/page.rb, line 287
def each_similar_url
  return enum_for(:each_similar_url) unless block_given?

  each do |result|
    yield result.similar_url if result.similar_url
  end
end
each_summary() { |summary| ... } click to toggle source

Iterates over each result’s summary within the page.

@yield [summary]

The given block will be passed the summary of each result in
the page.

@yieldparam [String] summary

The summary of a result in the page.

@return [Enumerator]

If no block is given, an Enumerator object will be returned.

@example

each_summary { |summary| puts summary }
# File lib/gscraper/search/page.rb, line 217
def each_summary
  return enum_for(:each_summary) unless block_given?

  each { |result| yield result.summary }
end
each_title() { |title| ... } click to toggle source

Iterates over each result’s title within the page.

@yield [title]

The given block will be passed the title of each result in
the page.

@yieldparam [String] title

The title of a result in the page.

@return [Enumerator]

If no block is given, an Enumerator object will be returned.

@example

each_title { |title| puts title }
# File lib/gscraper/search/page.rb, line 173
def each_title
  return enum_for(:each_title) unless block_given?

  each { |result| yield result.title }
end
each_url() { |url| ... } click to toggle source

Iterates over each result’s url within the page.

@yield [url]

The given block will be passed the URL of each result in
the page.

@yieldparam [URI::HTTP] url

The URL of a result in the page.

@return [Enumerator]

If no block is given, an Enumerator object will be returned.

@example

each_url { |url| puts url }
# File lib/gscraper/search/page.rb, line 195
def each_url
  return enum_for(:each_url) unless block_given?

  each { |result| yield result.url }
end
ranks() click to toggle source

Returns the ranks of the results in the page.

@return [Array<Integer>]

The ranks of the results.
# File lib/gscraper/search/page.rb, line 301
def ranks
  each_rank.to_a
end
ranks_of(&block) click to toggle source

Returns the ranks of the results that match the given block.

@yield [result]

The given block will be used to filter the results in the page.

@yieldparam [Result] result

A result in the page.

@return [Array<Integer>]

The ranks of the results which match the given block.

@example

page.ranks_of { |result| result.title =~ /awesome/ }
# File lib/gscraper/search/page.rb, line 380
def ranks_of(&block)
  results_with(&block).ranks
end
results_with_summary(summary) { |result| ... } click to toggle source

Selects the results with the matching summary.

@param [String, Regexp] summary

The summary to search for.

@yield [result]

The given block will be passed each matching result.

@yieldparam [Result] result

A result with the matching summary.

@return [Array<Result>]

The results with the matching summary.

@example

page.results_with_summary(/cheese cake/) # => Page

@example

page.results_with_summary(/Scientifically/) do |result|
  puts result.url
end
# File lib/gscraper/search/page.rb, line 123
def results_with_summary(summary)
  return enum_for(:results_with_summary,summary) unless block_given?

  results_with do |result|
    if result.summary.match(summary)
      yield result

      true
    end
  end
end
results_with_title(title) { |result| ... } click to toggle source

Selects the results with the matching title.

@param [String, Regexp] title

The title to search for.

@yield [result]

The given block will be passed each matching result.

@yieldparam [Result] result

A result with the matching title.

@return [Array<Result>]

The results with the matching title.

@example

page.results_with_title('hackety org') #=> Page

@example

page.results_with_title(/awesome/) do |result|
  puts result.url
end
# File lib/gscraper/search/page.rb, line 53
def results_with_title(title)
  return enum_for(:results_with_title,title) unless block_given?

  results_with do |result|
    if result.title.match(title)
      yield result

      true
    end
  end
end
results_with_url(url) { |result| ... } click to toggle source

Selects the results with the matching URL.

@param [String, Regexp] url

The URL to search for.

@yield [result]

The given block will be passed each matching result.

@yieldparam [Result] result

A result with the matching URL.

@return [Array<Result>]

The results with the matching URL.

@example

page.results_with_url(/\.com/) # => Page

@example

page.results_with_url(/^https:\/\//) do |result|
  puts result.title
end
# File lib/gscraper/search/page.rb, line 88
def results_with_url(url)
  return enum_for(:results_with_url,url) unless block_given?

  results_with do |result|
    if result.url.match(url)
      yield result

      true
    end
  end
end
similar_urls() click to toggle source

Returns the Similar Query URLs of the results in the page.

@return [Array<URI::HTTP>]

The Similar Query URLs of the results.
# File lib/gscraper/search/page.rb, line 361
def similar_urls
  each_similar_url.to_a
end
similar_urls_of(&block) click to toggle source

Returns the Similar Query URLs of the results that match the given block.

@yield [result]

The given block will be used to filter the results in the page.

@yieldparam [Result] result

A result in the page.

@return [Array<URI::HTTP>]

The Similar Query URLs of the results which match the given block.

@example

page.similar_urls_of { |result| result.title =~ /what if/ }
# File lib/gscraper/search/page.rb, line 495
def similar_urls_of(&block)
  results_with(&block).similar_urls
end
summaries() click to toggle source

Returns the summaries of the results in the page.

@return [Array<String>]

The summaries of the results.
# File lib/gscraper/search/page.rb, line 331
def summaries
  each_summary.to_a
end
summaries_of(&block) click to toggle source

Returns the summaries of the results that match the given block.

@yield [result]

The given block will be used to filter the results in the page.

@yieldparam [Result] result

A result in the page.

@return [Array<String>]

The summaries of the results which match the given block.

@example

page.summaries_of { |result| result.title =~ /what if/ }
# File lib/gscraper/search/page.rb, line 437
def summaries_of(&block)
  results_with(&block).summaries
end
titles() click to toggle source

Returns the titles of the results in the page.

@return [Array<String>]

The titles of the results.
# File lib/gscraper/search/page.rb, line 311
def titles
  each_title.to_a
end
titles_of(&block) click to toggle source

Returns the titles of the results that match the given block.

@yield [result]

The given block will be used to filter the results in the page.

@yieldparam [Result] result

A result in the page.

@return [Array<String>]

The titles of the results which match the given block.

@example

page.titles_of { |result| result.url.include?('www') }
# File lib/gscraper/search/page.rb, line 399
def titles_of(&block)
  results_with(&block).titles
end
urls() click to toggle source

Returns the URLs of the results in the page.

@return [Array<URI::HTTP>]

The URLs of the results.
# File lib/gscraper/search/page.rb, line 321
def urls
  each_url.to_a
end
urls_of(&block) click to toggle source

Returns the URLs of the results that match the given block.

@yield [result]

The given block will be used to filter the results in the page.

@yieldparam [Result] result

A result in the page.

@return [Array<URI::HTTP>]

The URLs of the results which match the given block.

@example

page.urls_of { |result| result.summary =~ /awesome pants/ }
# File lib/gscraper/search/page.rb, line 418
def urls_of(&block)
  results_with(&block).urls
end