Class: JSON::LD::Reader
- Inherits:
-
RDF::Reader
- Object
- RDF::Reader
- JSON::LD::Reader
- Defined in:
- lib/json/ld/reader.rb
Overview
A JSON-LD parser in Ruby.
Class Method Summary collapse
-
.options ⇒ Object
JSON-LD Reader options.
Instance Method Summary collapse
- #each_statement(&block) ⇒ Object
- #each_triple(&block) ⇒ Object
-
#initialize(input = $stdin, options = {}) {|reader| ... } ⇒ Reader
constructor
Initializes the RDF/JSON reader instance.
Constructor Details
#initialize(input = $stdin, options = {}) {|reader| ... } ⇒ Reader
Initializes the RDF/JSON reader instance.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/json/ld/reader.rb', line 35 def initialize(input = $stdin, = {}, &block) [:base_uri] ||= [:base] super do @options[:base] ||= base_uri.to_s if base_uri begin # Trim non-JSON stuff in script. @doc = if input.respond_to?(:read) input else StringIO.new(input.to_s.sub(%r(\A[^{\[]*)m, '').sub(%r([^}\]]*\Z)m, '')) end end if block_given? case block.arity when 0 then instance_eval(&block) else block.call(self) end end end end |
Class Method Details
.options ⇒ Object
JSON-LD Reader options
15 16 17 18 19 20 21 22 23 |
# File 'lib/json/ld/reader.rb', line 15 def self. super + [ RDF::CLI::Option.new( symbol: :compactArrays, datatype: TrueClass, on: ["--compact-arrays"], description: "Replaces arrays with just one element with that element during compaction.") {true}, ] end |