Class: Bio::LITDB

Inherits:
NCBIDB show all
Defined in:
lib/bio/db/litdb.rb

Overview

LITDB class

Constant Summary collapse

DELIMITER =

Delimiter

"\nEND\n"
RS =

Delimiter

DELIMITER
TAGSIZE =
12

Instance Method Summary collapse

Methods inherited from DB

#exists?, #fetch, #get, open, #tags

Constructor Details

#initialize(entry) ⇒ LITDB

Returns a new instance of LITDB.



27
28
29
# File 'lib/bio/db/litdb.rb', line 27

def initialize(entry)
  super(entry, TAGSIZE)
end

Instance Method Details

#authorObject

AUTHOR



84
85
86
# File 'lib/bio/db/litdb.rb', line 84

def author
  field_fetch('AUTHOR')
end

#entry_idObject

CODE



51
52
53
# File 'lib/bio/db/litdb.rb', line 51

def entry_id
  field_fetch('CODE')
end

#fieldObject

FIELD



61
62
63
# File 'lib/bio/db/litdb.rb', line 61

def field
  field_fetch('FIELD')
end

#journalObject

JOURNAL



66
67
68
# File 'lib/bio/db/litdb.rb', line 66

def journal
  field_fetch('JOURNAL')
end

#keywordObject

KEYWORD ‘;;’



76
77
78
79
80
81
# File 'lib/bio/db/litdb.rb', line 76

def keyword
  unless @data['KEYWORD']
    @data['KEYWORD'] = fetch('KEYWORD').split(/;;\s*/)
  end
  @data['KEYWORD']
end

#referenceObject

Returns



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/bio/db/litdb.rb', line 32

def reference
  hash = Hash.new('') 

  hash['authors'] = author.split(/;/).map {|x| x.sub(/,/, ', ')}
  hash['title']   = title 
  hash['journal'] = journal.gsub(/\./, '. ').strip

  vol = volume.split(/,\s+/)
  if vol.size > 1
    hash['volume'] = vol.shift.sub(/Vol\./, '')
    hash['pages'],
    hash['year'] = vol.pop.split(' ')
    hash['issue'] = vol.shift.sub(/No\./, '') unless vol.empty?
  end

  return Reference.new(hash) 
end

#titleObject

TITLE



56
57
58
# File 'lib/bio/db/litdb.rb', line 56

def title
  field_fetch('TITLE')
end

#volumeObject

VOLUME



71
72
73
# File 'lib/bio/db/litdb.rb', line 71

def volume
  field_fetch('VOLUME')
end