Class: Google::Result
- Inherits:
-
Object
- Object
- Google::Result
- Defined in:
- lib/domain-finder/google.rb
Overview
Simple class representing a single Google result
Instance Attribute Summary collapse
-
#cached ⇒ Object
Returns the value of attribute cached.
-
#snippet ⇒ Object
Returns the value of attribute snippet.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(result) ⇒ Result
constructor
A new instance of Result.
Constructor Details
#initialize(result) ⇒ Result
Returns a new instance of Result.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/domain-finder/google.rb', line 36 def initialize result @title = ( result / 'h2.r' ).inner_text @url = ( result / 'h2.r a' )[0]['href'] cached_element = ( result / 'div.std nobr a' )[0] @cached = cached_element['href'] if cached_element and cached_element.inner_text == 'Cached' snippet_element = ( result / 'div.std' )[0] if snippet_element @snippet = "" snippet_element.children.each do |this| break if this.to_s == '<br />' @snippet << this.inner_text end end end |
Instance Attribute Details
#cached ⇒ Object
Returns the value of attribute cached.
34 35 36 |
# File 'lib/domain-finder/google.rb', line 34 def cached @cached end |
#snippet ⇒ Object
Returns the value of attribute snippet.
34 35 36 |
# File 'lib/domain-finder/google.rb', line 34 def snippet @snippet end |
#title ⇒ Object
Returns the value of attribute title.
34 35 36 |
# File 'lib/domain-finder/google.rb', line 34 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
34 35 36 |
# File 'lib/domain-finder/google.rb', line 34 def url @url end |