Class: GoogleScholar::Article

Inherits:
Object
  • Object
show all
Extended by:
ActiveSupport::Memoizable
Defined in:
lib/google_scholar/article.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(doc) ⇒ Article

Returns a new instance of Article.



9
10
11
# File 'lib/google_scholar/article.rb', line 9

def initialize(doc)
  @doc = doc
end

Instance Attribute Details

#docObject (readonly)

Returns the value of attribute doc.



7
8
9
# File 'lib/google_scholar/article.rb', line 7

def doc
  @doc
end

Instance Method Details

#cites_countObject



35
36
37
38
39
# File 'lib/google_scholar/article.rb', line 35

def cites_count
  cites_element ?
    cites_element.text.gsub("Cited by ", "").to_i :
    0
end

#cites_elementObject



25
26
27
# File 'lib/google_scholar/article.rb', line 25

def cites_element
  doc.css('.gs_fl a').select{ |l| l.text =~ /^Cited by/ }.first
end


29
30
31
32
33
# File 'lib/google_scholar/article.rb', line 29

def cites_link
  cites_element ?
    GoogleScholar::ROOT_URL + cites_element['href'] :
    nil
end

#detailsObject



21
22
23
# File 'lib/google_scholar/article.rb', line 21

def details
  doc.css('.gs_a').first.text
end


17
18
19
# File 'lib/google_scholar/article.rb', line 17

def link
  doc.css('h3 a').first['href']
end

#titleObject



13
14
15
# File 'lib/google_scholar/article.rb', line 13

def title
  doc.css("h3").text
end