Class: SearchResult

Inherits:
Object
  • Object
show all
Defined in:
lib/googlesearch/search_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#excerptObject (readonly)

Returns the value of attribute excerpt.



2
3
4
# File 'lib/googlesearch/search_result.rb', line 2

def excerpt
  @excerpt
end

#indexObject (readonly)

Returns the value of attribute index.



2
3
4
# File 'lib/googlesearch/search_result.rb', line 2

def index
  @index
end

#languageObject (readonly)

Returns the value of attribute language.



2
3
4
# File 'lib/googlesearch/search_result.rb', line 2

def language
  @language
end

#mime_typeObject (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

#titleObject (readonly)

Returns the value of attribute title.



2
3
4
# File 'lib/googlesearch/search_result.rb', line 2

def title
  @title
end

#urlObject (readonly)

Returns the value of attribute url.



2
3
4
# File 'lib/googlesearch/search_result.rb', line 2

def url
  @url
end