class RDF::NQuads::Reader
Public Instance Methods
read_triple()
click to toggle source
Read a Quad, where the graph_name is optional
@return [Array] @see sw.deri.org/2008/07/n-quads/#grammar @since 0.4.0
# File lib/rdf/nquads.rb, line 64 def read_triple loop do readline.strip! # EOFError thrown on end of input line = @line # for backtracking input in case of parse error begin unless blank? || read_comment subject = read_uriref || read_node || fail_subject predicate = read_uriref(intern: true) || fail_predicate object = read_uriref || read_node || read_literal || fail_object graph_name = read_uriref || read_node if validate? && !read_eos log_error("Expected end of statement (found: #{current_line.inspect})", lineno: lineno, exception: RDF::ReaderError) end return [subject, predicate, object, {graph_name: graph_name}] end rescue RDF::ReaderError => e @line = line # this allows #read_value to work raise e end end end