Class: RDF::NQuads::Reader

Inherits:
RDF::NTriples::Reader show all
Defined in:
vendor/bundler/ruby/2.5.0/bundler/gems/rdf-c7356a6367f8/lib/rdf/nquads.rb

Constant Summary

Constants inherited from RDF::NTriples::Reader

RDF::NTriples::Reader::BLANK_NODE_LABEL, RDF::NTriples::Reader::COMMENT, RDF::NTriples::Reader::DATATYPE_URI, RDF::NTriples::Reader::ECHAR, RDF::NTriples::Reader::END_OF_STATEMENT, RDF::NTriples::Reader::ESCAPE_CHARS, RDF::NTriples::Reader::IRIREF, RDF::NTriples::Reader::IRI_RANGE, RDF::NTriples::Reader::LANGTAG, RDF::NTriples::Reader::LITERAL, RDF::NTriples::Reader::LITERAL_PLAIN, RDF::NTriples::Reader::LITERAL_WITH_DATATYPE, RDF::NTriples::Reader::LITERAL_WITH_LANGUAGE, RDF::NTriples::Reader::NODEID, RDF::NTriples::Reader::OBJECT, RDF::NTriples::Reader::PN_CHARS, RDF::NTriples::Reader::PN_CHARS_BASE, RDF::NTriples::Reader::PN_CHARS_U, RDF::NTriples::Reader::PREDICATE, RDF::NTriples::Reader::STRING_LITERAL_QUOTE, RDF::NTriples::Reader::SUBJECT, RDF::NTriples::Reader::UCHAR, RDF::NTriples::Reader::UCHAR4, RDF::NTriples::Reader::UCHAR8, RDF::NTriples::Reader::URIREF, RDF::NTriples::Reader::U_CHARS1, RDF::NTriples::Reader::U_CHARS2

Instance Attribute Summary

Attributes inherited from Reader

#options

Instance Method Summary collapse

Methods inherited from RDF::NTriples::Reader

parse_literal, parse_node, parse_object, parse_predicate, parse_subject, parse_uri, #read_comment, #read_eos, #read_literal, #read_node, #read_uriref, #read_value, unescape, unserialize

Methods included from Util::Logger

#log_debug, #log_depth, #log_error, #log_fatal, #log_info, #log_recover, #log_recovering?, #log_statistics, #log_warn, #logger

Methods inherited from Reader

#base_uri, #canonicalize?, #close, each, #each_statement, #each_triple, #encoding, #fail_object, #fail_predicate, #fail_subject, for, format, #initialize, #intern?, #lineno, open, options, #prefix, #prefixes, #prefixes=, #read_statement, #rewind, #to_sym, to_sym, #valid?, #validate?

Methods included from Util::Aliasing::LateBound

#alias_method

Methods included from Enumerable

add_entailment, #dump, #each_graph, #each_object, #each_predicate, #each_quad, #each_statement, #each_subject, #each_term, #each_triple, #entail, #enum_graph, #enum_object, #enum_predicate, #enum_quad, #enum_statement, #enum_subject, #enum_term, #enum_triple, #graph_names, #has_graph?, #has_object?, #has_predicate?, #has_quad?, #has_statement?, #has_subject?, #has_term?, #has_triple?, #invalid?, #method_missing, #objects, #predicates, #project_graph, #quads, #respond_to_missing?, #statements, #subjects, #supports?, #terms, #to_a, #to_h, #to_set, #triples, #valid?, #validate!

Methods included from Isomorphic

#bijection_to, #isomorphic_with?

Methods included from Countable

#count, #empty?

Methods included from Readable

#readable?

Constructor Details

This class inherits a constructor from RDF::Reader

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RDF::Enumerable

Instance Method Details

#read_tripleArray

Read a Quad, where the graph_name is optional

Returns:

See Also:

Since:

  • 0.4.0



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-c7356a6367f8/lib/rdf/nquads.rb', line 65

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