Class: GScholar::Paper

Inherits:
Object
  • Object
show all
Includes:
Citeable
Defined in:
lib/gscholar/paper.rb

Constant Summary collapse

CITATION_PER_PAGE =
20

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Citeable

#author, #citation, included, #title, #year

Constructor Details

#initialize(id) ⇒ Paper

Returns a new instance of Paper.



12
13
14
15
# File 'lib/gscholar/paper.rb', line 12

def initialize(id)
  @id = id
  @bibtex = Utils::LazyProxy.new { Utils.fetch(bibtex_url).body }
end

Instance Attribute Details

#bibtexObject (readonly) Also known as: to_s

Returns the value of attribute bibtex.



7
8
9
# File 'lib/gscholar/paper.rb', line 7

def bibtex
  @bibtex
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/gscholar/paper.rb', line 7

def id
  @id
end

Instance Method Details

#citations(range = nil) ⇒ Object



21
22
23
24
25
26
27
28
# 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

#citedObject



17
18
19
# File 'lib/gscholar/paper.rb', line 17

def cited
  @cited ||= Utils.fetch(cluster_url).body[/>Cited by (\d+)<\/a>/, 1].to_i
end