class GPG::TempPathHelper
Public Class Methods
create() { |path| ... }
click to toggle source
# File lib/pgp/gpg/temp_path_helper.rb, line 5 def self.create(&block) path = File.join(Dir.tmpdir, random_string) yield(path) if block path ensure delete(path) end
Private Class Methods
delete(path)
click to toggle source
# File lib/pgp/gpg/temp_path_helper.rb, line 17 def self.delete(path) if File.exists?(path) File.delete(path) end end
random_string(length=20)
click to toggle source
# File lib/pgp/gpg/temp_path_helper.rb, line 23 def self.random_string(length=20) (0...length).map { (65 + rand(26)).chr }.join end