Class: Keys::Swift::Writer

Inherits:
Object
  • Object
show all
Defined in:
lib/core/utils/swift/writer.rb

Instance Method Summary collapse

Constructor Details

#initialize(mapped_keys:, secure_key_bytes:) ⇒ Writer

Initialize the writer with the mapped keys and the secure key bytes

Parameters:

  • mapped_keys (Array<Hash>)

    The mapped keys

  • secure_key_bytes (Array<UInt8>)

    The secure key bytes



18
19
20
21
22
23
# File 'lib/core/utils/swift/writer.rb', line 18

def initialize(mapped_keys:, secure_key_bytes:)
  self.mapped_keys = mapped_keys
  self.secure_key_bytes = secure_key_bytes
  self.key_file = "#{SWIFT_PACKAGE_NAME}.swift"
  self.key_directory = "#{SWIFT_PACKAGE_DIRECTORY}/Sources/#{SWIFT_PACKAGE_NAME}"
end

Instance Method Details

#writeObject

Write the keys to the file



26
27
28
29
30
31
# File 'lib/core/utils/swift/writer.rb', line 26

def write
  # Write the file
  File.open("#{key_directory}/#{key_file}", 'w') do |file|
    file.write(key_swift_file_template(content: formatted_keys))
  end
end