class GScholar::Paper

Constants

CITATION_PER_PAGE

Attributes

bibtex[R]
id[R]
to_s[R]

Public Class Methods

new(id) click to toggle source
# File lib/gscholar/paper.rb, line 12
def initialize(id)
  @id = id
  @bibtex = Utils::LazyProxy.new { Utils.fetch(bibtex_url).body }
end

Public Instance Methods

citations(range = nil) click to toggle source
# File lib/gscholar/paper.rb, line 21
def citations(range = nil)
  rst = []
  while true
    links = Utils.fetch(citations_url(rst.size, range)).links_with(:text => "Import into BibTeX")
    return rst if links.empty?
    rst += links.map {|link| Citation.new(link.href[/info:([^:]+):/, 1]) }
  end
end
cited() click to toggle source
# File lib/gscholar/paper.rb, line 17
def cited
  @cited ||= Utils.fetch(cluster_url).body[/>Cited by (\d+)<\/a>/, 1].to_i
end

Private Instance Methods

bibtex_url() click to toggle source
# File lib/gscholar/paper.rb, line 31
def bibtex_url
  "http://scholar.google.com/scholar.bib?q=info:#{key}:scholar.google.com/&output=citation"
end
citations_url(start = 0, range = nil) click to toggle source
# File lib/gscholar/paper.rb, line 39
def citations_url(start = 0, range = nil)
  "http://scholar.google.com/scholar?cites=#{@id}&num=20&start=#{start}&as_ylo=#{range}"
end
cluster_url() click to toggle source
# File lib/gscholar/paper.rb, line 35
def cluster_url
  "http://scholar.google.com/scholar?cluster=#{@id}"
end
key() click to toggle source
# File lib/gscholar/paper.rb, line 43
def key
  @key ||= Utils.fetch(cluster_url).link_with(:text => "Related articles").href[/related:([^:]+):/, 1]
end