Class: BibTeX::Bibliography::RDFConverter
- Inherits:
-
Object
- Object
- BibTeX::Bibliography::RDFConverter
- Defined in:
- lib/bibtex/bibliography/rdf_converter.rb
Class Method Summary collapse
-
.convert(bibtex) ⇒ RDF::Graph
converts a BibTeX Bibliography to RDF.
Instance Method Summary collapse
-
#convert! ⇒ RDF::Graph
The RDF graph of this bibliography.
-
#initialize(bibtex, graph = RDF::Graph.new) ⇒ RDFConverter
constructor
A new instance of RDFConverter.
Constructor Details
#initialize(bibtex, graph = RDF::Graph.new) ⇒ RDFConverter
Returns a new instance of RDFConverter.
9 10 11 12 13 |
# File 'lib/bibtex/bibliography/rdf_converter.rb', line 9 def initialize(bibtex, graph = RDF::Graph.new) @bibtex = bibtex @graph = graph @agent = {} end |
Class Method Details
.convert(bibtex) ⇒ RDF::Graph
converts a BibTeX Bibliography to RDF
4 5 6 |
# File 'lib/bibtex/bibliography/rdf_converter.rb', line 4 def self.convert(bibtex) new(bibtex).convert! end |
Instance Method Details
#convert! ⇒ RDF::Graph
Returns the RDF graph of this bibliography.
16 17 18 19 20 21 22 |
# File 'lib/bibtex/bibliography/rdf_converter.rb', line 16 def convert! bibtex.q('@entry').each do |entry| BibTeX::Entry::RDFConverter.convert(entry, graph, agent) end graph end |