Class: Google::Scholar::Author

Inherits:
Object
  • Object
show all
Defined in:
lib/google/scholar/author.rb

Instance Method Summary collapse

Constructor Details

#initialize(document) ⇒ Author

Returns a new instance of Author.



5
6
7
# File 'lib/google/scholar/author.rb', line 5

def initialize(document)
  @summary_doc = document
end

Instance Method Details

#articlesObject



26
27
28
# File 'lib/google/scholar/author.rb', line 26

def articles
  @articles ||= Google::Scholar::ArticleEnumerator.new(Google::Scholar::Scraper.new(nil,self.full_profile))
end

#author_urlObject



14
15
16
# File 'lib/google/scholar/author.rb', line 14

def author_url
  @author_url ||= "#{Google::Scholar.google_url}#{@summary_doc.css("td:last a").first.attr("href")}&pagesize=100"
end

#citation_countObject



11
12
13
# File 'lib/google/scholar/author.rb', line 11

def citation_count
  @citation_count ||= @summary_doc.css("td:last").children.reject{|x| !x.text?}.last.text.split(" ").last.to_i
end

#citationsObject



20
21
22
# File 'lib/google/scholar/author.rb', line 20

def citations
  full_profile.css("#stats td.cit-data").first.text.to_i
end

#full_profileObject



17
18
19
# File 'lib/google/scholar/author.rb', line 17

def full_profile
  @full_profile ||= Google::Scholar::Scraper.new(author_url).documents.first
end

#idObject



23
24
25
# File 'lib/google/scholar/author.rb', line 23

def id
  @id ||= @summary_doc.css("td:last a:first").attr("href").to_s.match(/user=(.*)&/)[1]
end

#nameObject



8
9
10
# File 'lib/google/scholar/author.rb', line 8

def name
  @name ||= @summary_doc.css("td:last a:first").text.strip.gsub('\n','')
end