def encrypt
bad_key = @email_addresses.empty?
if File.exists?(@file)
unless File.readable?(@file)
raise InvalidFileException.new("File at #{@file} is not readable.") and return
end
else
raise InvalidFileException.new("File at #{@file} does not exist.") and return
end
@email_addresses.each do |add|
unless Gpgr::Keys.public_key_installed?(add)
bad_key = true
end
end
if bad_key
raise InvalidEmailException.new("One or more of the e-mail addresses you supplied don't have valid keys assigned!")
else
command = Gpgr.command + " -q --no-verbose --yes -a -o #{@file_output} -r " + @email_addresses.join(' -r ') + " -e #{@file}"
system(command)
end
end