class RDF::YodaTriples::Reader
Public Instance Methods
read_triple()
click to toggle source
# File lib/rdf/yoda_triples.rb, line 33 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 object = read_uriref || read_node || read_literal || fail_object subject = read_uriref || read_node || fail_subject predicate = read_uriref(:intern => true) || fail_predicate if validate? && !read_eos raise RDF::ReaderError.new("ERROR [line #{lineno}] Expected end of statement (found: #{current_line.inspect})", lineno: lineno) end return [subject, predicate, object] end rescue RDF::ReaderError => e @line = line # this allows #read_value to work raise e end end end