Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/extcite/methods_string.rb,
lib/extcite/methods_string.rb

Overview

String methods

Instance Method Summary collapse

Instance Method Details

#make_bib_arxiv(id) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/extcite/methods_string.rb', line 14

def make_bib_arxiv(id)
	# prep xml
	xml = Oga.parse_xml(self)	# author = xml.xpath('//author//name')[0].text.downcase.gsub(/\s|\./, '_')

	year = DateTime.strptime(xml.xpath('//updated')[0].text).year

	# make bib citation
	bib = BibTeX::Bibliography.new
	bib << BibTeX::Entry.new({
	  :bibtex_type => :article,
	  :url => xml.xpath('//entry/id').text,
	  :author => xml.xpath('//author//name').collect { |x| x.text }.join(' and '),
	  :eprint => id,
	  :title => xml.xpath('//entry//title').text,
	  :year => year
	})
	return bib.to_s
end

#write_bib(file) ⇒ Object



6
7
8
9
10
# File 'lib/extcite/methods_string.rb', line 6

def write_bib(file)
  File.open(file, 'a') do |f|
    f.puts self
  end
end