Class: GScraper::Search::Result
- Inherits:
-
Object
- Object
- GScraper::Search::Result
- Defined in:
- lib/gscraper/search/result.rb
Instance Attribute Summary collapse
-
#cached_url ⇒ Object
readonly
URL of the cached result page.
-
#rank ⇒ Object
readonly
Rank of the result page.
-
#similar_url ⇒ Object
readonly
URL of the similar results Query.
-
#summary ⇒ Object
readonly
Summary from the result page.
-
#title ⇒ Object
readonly
Title of the result page.
-
#url ⇒ Object
readonly
URL of the result page.
Instance Method Summary collapse
-
#cached_page ⇒ Mechanize::Page
Fetches the Cached Page of the result.
-
#initialize(rank, title, url, summary, cached_url = nil, similar_url = nil) ⇒ Result
constructor
Creates a new Result object.
-
#page ⇒ Mechanize::Page
Fetches the page of the result.
-
#to_s ⇒ String
The result's title.
Constructor Details
#initialize(rank, title, url, summary, cached_url = nil, similar_url = nil) ⇒ Result
Creates a new GScraper::Search::Result object.
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/gscraper/search/result.rb', line 64 def initialize(rank,title,url,summary,cached_url=nil,similar_url=nil) @agent = GScraper.web_agent @rank = rank @title = title @url = url @summary = summary @cached_url = cached_url @similar_url = similar_url end |
Instance Attribute Details
#cached_url ⇒ Object (readonly)
URL of the cached result page
41 42 43 |
# File 'lib/gscraper/search/result.rb', line 41 def cached_url @cached_url end |
#rank ⇒ Object (readonly)
Rank of the result page
29 30 31 |
# File 'lib/gscraper/search/result.rb', line 29 def rank @rank end |
#similar_url ⇒ Object (readonly)
URL of the similar results Query
44 45 46 |
# File 'lib/gscraper/search/result.rb', line 44 def similar_url @similar_url end |
#summary ⇒ Object (readonly)
Summary from the result page
38 39 40 |
# File 'lib/gscraper/search/result.rb', line 38 def summary @summary end |
#title ⇒ Object (readonly)
Title of the result page
32 33 34 |
# File 'lib/gscraper/search/result.rb', line 32 def title @title end |
#url ⇒ Object (readonly)
URL of the result page
35 36 37 |
# File 'lib/gscraper/search/result.rb', line 35 def url @url end |
Instance Method Details
#cached_page ⇒ Mechanize::Page
Fetches the Cached Page of the result.
91 92 93 |
# File 'lib/gscraper/search/result.rb', line 91 def cached_page @agent.get(@cached_url) if @cached_url end |
#page ⇒ Mechanize::Page
Fetches the page of the result.
81 82 83 |
# File 'lib/gscraper/search/result.rb', line 81 def page @agent.get(@url) end |
#to_s ⇒ String
The result's title.
101 102 103 |
# File 'lib/gscraper/search/result.rb', line 101 def to_s @title.to_s end |