Class: BibliographicalImporter::JSON::Reference

Inherits:
Object
  • Object
show all
Defined in:
lib/bibliographical_importer/json.rb

Overview

Process references inside JSON

Instance Method Summary collapse

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

#doiObject



39
40
41
# File 'lib/bibliographical_importer/json.rb', line 39

def doi
  @v['DOI']
end

#doi_sObject



49
50
51
# File 'lib/bibliographical_importer/json.rb', line 49

def doi_s
  doi ? "doi:#{doi}":""
end

#pagesObject



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_sObject



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