lib/json/ld/writer.rb in json-ld-0.1.2 vs lib/json/ld/writer.rb in json-ld-0.1.3

- old
+ new

@@ -90,11 +90,11 @@ # @yieldparam [RDF::Writer] writer def initialize(output = $stdout, options = {}, &block) options[:base_uri] ||= options[:base] if options.has_key?(:base) options[:base] ||= options[:base_uri] if options.has_key?(:base_uri) super do - @graph = RDF::Graph.new + @repo = RDF::Graph.new if block_given? case block.arity when 0 then instance_eval(&block) else block.call(self) @@ -108,19 +108,19 @@ # # @param [Graph] graph # @return [void] def write_graph(graph) debug {"Add graph #{graph.inspect}"} - @graph = graph + @repo = graph end ## # Adds a statement to be serialized # @param [RDF::Statement] statement # @return [void] def write_statement(statement) - @graph.insert(statement) + @repo.insert(statement) end ## # Addes a triple to be serialized # @param [RDF::Resource] subject @@ -128,11 +128,11 @@ # @param [RDF::Value] object # @return [void] # @raise [NotImplementedError] unless implemented in subclass # @abstract def write_triple(subject, predicate, object) - @graph.insert(Statement.new(subject, predicate, object)) + @repo.insert(Statement.new(subject, predicate, object)) end ## # Outputs the Serialized JSON-LD representation of all stored statements. # @@ -143,10 +143,10 @@ # @see #write_triple def write_epilogue @debug = @options[:debug] # Turn graph into a triple array - statements = @graph.each_statement.to_a + statements = @repo.each_statement.to_a debug("writer") { "serialize #{statements.length} statements, #{@options.inspect}"} result = API.fromRDF(statements, nil, @options) # If we were provided a context, or prefixes, use them to compact the output context = RDF::Util::File.open_file(@options[:context]) if @options[:context].is_a?(String)