Class: Izokatu::FileExporter

Inherits:
Exporter show all
Defined in:
lib/izokatu/exporter/file_exporter.rb

Overview

Izokatu exporter for exporting data in some file

Constant Summary

Constants included from Helpers

Helpers::EC_CIPHER, Helpers::KEY_SYMBOL, Helpers::RBNACL_KEY_CLASSES

Instance Attribute Summary collapse

Attributes inherited from Exporter

#data

Instance Method Summary collapse

Methods included from Callable

#call

Methods included from Helpers

#decode_data, #encode_data, #export_data, #export_decrypted!, #export_encrypted!, #generate_ec_keypair, #generate_rbnacl_keypair, #generate_rsa_keypair, #import_data, #import_encrypted!, #import_encrypted_in_options!

Constructor Details

#initialize(data:, filename:, encode:) ⇒ FileExporter

Initializing data for file export

Parameters:

  • data (#data)
  • filename (#filename)
  • encode (TrueClass || FalseClass)

    Enable/disable encoding of exported data

Since:

  • 0.1.0



17
18
19
20
# File 'lib/izokatu/exporter/file_exporter.rb', line 17

def initialize(data:, filename:, encode:)
  super(data: data, encode: encode)
  @filename = filename
end

Instance Attribute Details

#filenameString (readonly)

Returns name of file to export.

Returns:

  • (String)

    name of file to export



7
8
9
# File 'lib/izokatu/exporter/file_exporter.rb', line 7

def filename
  @filename
end

Instance Method Details

#performObject

Performing export of initialized data

Since:

  • 0.1.0



26
27
28
29
# File 'lib/izokatu/exporter/file_exporter.rb', line 26

def perform
  File.write(filename, JSON.generate(data))
  nil
end