Class: BibliographicalImporter::JSON::Reference
- Inherits:
-
Object
- Object
- BibliographicalImporter::JSON::Reference
- Defined in:
- lib/bibliographical_importer/json.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.
36 37 38 |
# File 'lib/bibliographical_importer/json.rb', line 36 def initialize(v) @v=v end |
Instance Method Details
#doi ⇒ Object
39 40 41 |
# File 'lib/bibliographical_importer/json.rb', line 39 def doi @v['DOI'] end |
#doi_s ⇒ Object
49 50 51 |
# File 'lib/bibliographical_importer/json.rb', line 49 def doi_s doi ? "doi:#{doi}":"" end |
#pages ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/bibliographical_importer/json.rb', line 42 def pages if @v['first-page'] and @v['last-page'] "#{@v['first-page']}-#{@v['last-page']}" else "" end end |
#to_s ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/bibliographical_importer/json.rb', line 52 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 |