Method: JSON::LD::API#initialize
- Defined in:
- lib/json/ld/api.rb
#initialize(input, context, options = {}) {|api| ... } ⇒ API
Initialize the API, reading in any document and setting global options
If set to true, the JSON-LD processor will use the expanded rdf:type IRI as the property instead of ‘@type` when converting from RDF.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/json/ld/api.rb', line 53 def initialize(input, context, = {}, &block) @options = {:compactArrays => true}.merge() @value = case input when Array, Hash then input.dup when IO, StringIO then JSON.parse(input.read) when String content = nil RDF::Util::File.open_file(input) {|f| content = JSON.parse(f.read)} content end @context = EvaluationContext.new() @context = @context.parse(context) if context if block_given? case block.arity when 0, -1 then instance_eval(&block) else block.call(self) end end end |