Class: BibTeX::Entry::BibTeXMLConverter
- Inherits:
-
Object
- Object
- BibTeX::Entry::BibTeXMLConverter
- Defined in:
- lib/bibtex/entry/bibtexml_converter.rb
Class Method Summary collapse
Instance Method Summary collapse
- #convert! ⇒ Object
- #fields ⇒ Object
-
#initialize(bibtex, options = {}) ⇒ BibTeXMLConverter
constructor
A new instance of BibTeXMLConverter.
Constructor Details
#initialize(bibtex, options = {}) ⇒ BibTeXMLConverter
Returns a new instance of BibTeXMLConverter.
8 9 10 11 |
# File 'lib/bibtex/entry/bibtexml_converter.rb', line 8 def initialize(bibtex, = {}) @bibtex = bibtex @options = end |
Class Method Details
.convert(bibtex, options = {}) ⇒ Object
4 5 6 |
# File 'lib/bibtex/entry/bibtexml_converter.rb', line 4 def self.convert(bibtex, = {}) new(bibtex, ).convert! end |
Instance Method Details
#convert! ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/bibtex/entry/bibtexml_converter.rb', line 13 def convert! xml = REXML::Element.new('bibtex:entry') xml.attributes['id'] = bibtex.key fields xml.add_element(entry) xml end |
#fields ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/bibtex/entry/bibtexml_converter.rb', line 23 def fields bibtex.fields.each do |key, value| field = REXML::Element.new("bibtex:#{key}") if [:extended] && value.name? value.each { |n| field.add_element(n.to_xml) } else field.text = value.to_s() end entry.add_element(field) end end |