Class: BibTeX::Bibliography::RDFConverter

Inherits:
Object
  • Object
show all
Defined in:
lib/bibtex/bibliography/rdf_converter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bibtex, graph = RDF::Graph.new) ⇒ RDFConverter

Returns a new instance of RDFConverter.

Parameters:



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

Returns:

  • (RDF::Graph)

    the RDF graph of the bibliography



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.

Returns:

  • (RDF::Graph)

    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