Module: DOIHelpers
- Included in:
 - CrossrefDoi, CrossrefDoi, PdfProcessor, Record, Reference, Reference, ReferenceMethods, ReferenceProcessor, ReferenceProcessor, SemanticScholar::Remote
 
- Defined in:
 - lib/doi_helpers.rb
 
Overview
Methods to parse and show DOI
Instance Method Summary collapse
- 
  
    
      #a_doi(doi)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns an <a> tag to link a DOI.
 - 
  
    
      #doi_without_http(doi)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Return the doi without the http part.
 - 
  
    
      #find_doi(text)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
find DOI on a text.
 - 
  
    
      #url_doi(doi)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Add http to doi.
 
Instance Method Details
#a_doi(doi) ⇒ Object
Returns an <a> tag to link a DOI
      41 42 43 44  | 
    
      # File 'lib/doi_helpers.rb', line 41 def a_doi(doi) url_doi_=url_doi(doi) "<a target='_blank' href='#{url_doi_}'>#{url_doi_}</a>" end  | 
  
#doi_without_http(doi) ⇒ Object
Return the doi without the http part
      46 47 48 49  | 
    
      # File 'lib/doi_helpers.rb', line 46 def doi_without_http(doi) return nil if doi.nil? doi.gsub(/http.+doi.org\// ,"") end  | 
  
#find_doi(text) ⇒ Object
find DOI on a text
      54 55 56 57 58 59 60  | 
    
      # File 'lib/doi_helpers.rb', line 54 def find_doi(text) if text=~/\b(10[.][0-9]{4,}(?:[.][0-9]+)*\/(?:(?!["&\'<>])\S)+)\b/ return $1 else return nil end end  | 
  
#url_doi(doi) ⇒ Object
Add http to doi
      33 34 35 36 37 38 39  | 
    
      # File 'lib/doi_helpers.rb', line 33 def url_doi(doi) if doi=~/http/ doi else "http://doi.org/#{doi}" end end  |