Sha256: 4c0949049fa2de73b6f608217d05fc244df6926c02bd962d92cf3e1eec386d78

Contents?: true

Size: 624 Bytes

Versions: 3

Compression:

Stored size: 624 Bytes

Contents

class BibTeX::Bibliography::RDFConverter
  # converts a BibTeX Bibliography to RDF
  # @return [RDF::Graph] the RDF graph of the bibliography
  def self.convert(bibtex)
    new(bibtex).convert!
  end

  # @param [BibTeX::Entry] the bibliography to convert
  def initialize(bibtex, graph = RDF::Graph.new)
    @bibtex = bibtex
    @graph = graph
    @agent = {}
  end

  # @return [RDF::Graph] the RDF graph of this bibliography
  def convert!
    bibtex.q('@entry').each do |entry|
      BibTeX::Entry::RDFConverter.convert(entry, graph, agent)
    end

    graph
  end

  private

  attr_reader :bibtex, :graph, :agent
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bibtex-ruby-3.1.2 lib/bibtex/bibliography/rdf_converter.rb
bibtex-ruby-3.1.1 lib/bibtex/bibliography/rdf_converter.rb
bibtex-ruby-3.1.0 lib/bibtex/bibliography/rdf_converter.rb