Class: PdfExtract::Resolve::Sigg

Inherits:
Object
  • Object
show all
Defined in:
lib/references/resolve.rb

Class Method Summary collapse

Class Method Details

.find(ref) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/references/resolve.rb', line 10

def self.find ref
  url = "http://api.labs.crossref.org/search?q=#{CGI.escape(ref)}"
  resolved = {}
  begin
    doc = Nokogiri::HTML(open url)

    result = doc.at_css "div.result"
    unless result.nil?
      score = result.at_css("span.cr_score").content.to_s
      if score.to_i >= 90
        doi = result.at_css "span.doi"
        resolved[:doi] = doi.content.sub "http://dx.doi.org/", ""
      end
    end
  rescue
  end
  resolved
end