Class: BibliographicalImporter::JSONApiCrossref::Reference
- Inherits:
 - 
      Object
      
        
- Object
 - BibliographicalImporter::JSONApiCrossref::Reference
 
 
- Defined in:
 - lib/bibliographical_importer/json_api_crossref.rb
 
Overview
Process references inside JSON
Instance Method Summary collapse
- #doi ⇒ Object
 - #doi_s ⇒ Object
 - 
  
    
      #initialize(v)  ⇒ Reference 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Reference.
 - #pages ⇒ Object
 - #to_s ⇒ Object
 
Constructor Details
#initialize(v) ⇒ Reference
Returns a new instance of Reference.
      35 36 37  | 
    
      # File 'lib/bibliographical_importer/json_api_crossref.rb', line 35 def initialize(v) @v=v end  | 
  
Instance Method Details
#doi ⇒ Object
      38 39 40  | 
    
      # File 'lib/bibliographical_importer/json_api_crossref.rb', line 38 def doi @v['DOI'] end  | 
  
#doi_s ⇒ Object
      48 49 50  | 
    
      # File 'lib/bibliographical_importer/json_api_crossref.rb', line 48 def doi_s doi ? "doi:#{doi}":"" end  | 
  
#pages ⇒ Object
      41 42 43 44 45 46 47  | 
    
      # File 'lib/bibliographical_importer/json_api_crossref.rb', line 41 def pages if @v['first-page'] and @v['last-page'] "#{@v['first-page']}-#{@v['last-page']}" else "" end end  | 
  
#to_s ⇒ Object
      51 52 53 54 55 56 57 58 59  | 
    
      # File 'lib/bibliographical_importer/json_api_crossref.rb', line 51 def to_s if @v['author'] and @v['article-title'] "#{@v['author']} (#{@v['year']}). #{@v['article-title']}. #{@v['journal-title']}, #{@v['volume']}, #{pages}. #{doi_s}" elsif @v['DOI'] doi_s else @v.map {|v| "#{v[0]}:#{v[1]}"}.join(";") end end  |