Class: Reddy::N3Parser
Instance Attribute Summary
Attributes inherited from Parser
Instance Method Summary collapse
-
#parse(stream, uri = nil, options = {}, &block) ⇒ Graph
Parse N3 document from a string or input stream to closure or graph.
Methods inherited from Parser
#initialize, n3_parser, parse, rdfa_parser, rdfxml_parser
Constructor Details
This class inherits a constructor from Reddy::Parser
Instance Method Details
#parse(stream, uri = nil, options = {}, &block) ⇒ Graph
Parse N3 document from a string or input stream to closure or graph.
Optionally, the stream may be a Nokogiri::HTML::Document or Nokogiri::XML::Document With a block, yeilds each statement with URIRef, BNode or Literal elements
- options[:debug]
-
Array to place debug messages
- options[:strict]
-
Abort or proceed on error
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/reddy/n3parser.rb', line 23 def parse(stream, uri = nil, = {}, &block) # :yields: triple super @callback = block parser = N3GrammerParser.new @doc = stream.respond_to?(:read) ? stream.read : stream document = parser.parse(@doc) unless document reason = parser.failure_reason raise ParserException.new(reason) end process_directives(document) process_statements(document) @graph end |