Class: Google::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/domain-finder/google.rb

Overview

Simple class representing a single Google result

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#cachedObject

Returns the value of attribute cached.



34
35
36
# File 'lib/domain-finder/google.rb', line 34

def cached
  @cached
end

#snippetObject

Returns the value of attribute snippet.



34
35
36
# File 'lib/domain-finder/google.rb', line 34

def snippet
  @snippet
end

#titleObject

Returns the value of attribute title.



34
35
36
# File 'lib/domain-finder/google.rb', line 34

def title
  @title
end

#urlObject

Returns the value of attribute url.



34
35
36
# File 'lib/domain-finder/google.rb', line 34

def url
  @url
end