RubyFileWriteBinaryAction

InfoGeneratePackages

The code is a Ruby module named Sublayer, which contains a nested module called Actions. Inside the Actions module, there's a class named WriteFileAction that inherits from a base class not shown here. The WriteFileAction class is designed to handle writing content to a file. It is initialized with the contents to write to the file and the file path. The call method writes the provided contents to the specified file path in binary mode ('wb'), ensuring that the file is written as binary data. This class encapsulates the functionality to write data to files, which can be reused across applications that include this module.

module Sublayer
  module Actions
    class WriteFileAction < Base
      def initialize(file_contents:, file_path:)
        @file_contents = file_contents
        @file_path = file_path
      end

      def call
        File.open(@file_path, 'wb') do |file|
          file.write(@file_contents)
        end
      end
    end
  end
end