class PredictionIO::FileExporter

This class contains methods that allow you to export data for import though:

$ pio import FILENAME

Public Class Methods

new(filename) click to toggle source
# File lib/predictionio/file_exporter.rb, line 8
def initialize(filename)
  @filename = filename
  @file = File.open(@filename, 'w')
end

Public Instance Methods

close() click to toggle source
# File lib/predictionio/file_exporter.rb, line 25
def close
  @file.close
end
create_event(event, entity_type, entity_id, optional = {}) click to toggle source
# File lib/predictionio/file_exporter.rb, line 13
def create_event(event, entity_type, entity_id, optional = {})

  h = optional
  h.key?('eventTime') || h['eventTime'] = DateTime.now.to_s
  h['event'] = event
  h['entityType'] = entity_type
  h['entityId'] = entity_id

  json = h.to_json
  @file.write("#{json}\n")
end