Class: Rialto::Etl::Writers::JsonldWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/rialto/etl/writers/jsonld_writer.rb

Overview

Write JSON-LD records. This writer conforms to Traject’s writer class interface, supporting #initialize, #put, and #close

Instance Method Summary collapse

Constructor Details

#initialize(_) ⇒ JsonldWriter

Constructor



14
# File 'lib/rialto/etl/writers/jsonld_writer.rb', line 14

def initialize(_); end

Instance Method Details

#closeObject

Print a JSON representation of the records with the JSON-LD context object attached



28
29
30
# File 'lib/rialto/etl/writers/jsonld_writer.rb', line 28

def close
  $stdout.puts records.to_json
end

#put(context) ⇒ Array

Append the hash representing a single mapped record to the list of records held in memory

Parameters:

  • context (Traject::Indexer::Context)

    a Traject context object containing the output of the mapping

Returns:

  • (Array)

    a list of all records mapped



22
23
24
# File 'lib/rialto/etl/writers/jsonld_writer.rb', line 22

def put(context)
  records << context.output_hash
end