Class: SearchResult
- Inherits:
-
Object
- Object
- SearchResult
- Defined in:
- lib/googlesearch/search_result.rb
Instance Attribute Summary collapse
-
#excerpt ⇒ Object
readonly
Returns the value of attribute excerpt.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#mime_type ⇒ Object
readonly
Returns the value of attribute mime_type.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(doc) ⇒ SearchResult
constructor
A new instance of SearchResult.
Constructor Details
#initialize(doc) ⇒ SearchResult
Returns a new instance of SearchResult.
3 4 5 6 7 8 9 10 |
# File 'lib/googlesearch/search_result.rb', line 3 def initialize(doc) @index = doc.attributes["N"].text.to_i @mime_type = doc.attributes["MIME"] ? doc.attributes["MIME"].text : nil @url = doc.xpath('U').text @title = doc.xpath('T').text @excerpt = doc.xpath('S').text @language = doc.xpath('LANG').text end |
Instance Attribute Details
#excerpt ⇒ Object (readonly)
Returns the value of attribute excerpt.
2 3 4 |
# File 'lib/googlesearch/search_result.rb', line 2 def excerpt @excerpt end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
2 3 4 |
# File 'lib/googlesearch/search_result.rb', line 2 def index @index end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
2 3 4 |
# File 'lib/googlesearch/search_result.rb', line 2 def language @language end |
#mime_type ⇒ Object (readonly)
Returns the value of attribute mime_type.
2 3 4 |
# File 'lib/googlesearch/search_result.rb', line 2 def mime_type @mime_type end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
2 3 4 |
# File 'lib/googlesearch/search_result.rb', line 2 def title @title end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
2 3 4 |
# File 'lib/googlesearch/search_result.rb', line 2 def url @url end |