class SendmailQWriter
Public Class Methods
new()
click to toggle source
# File lib/sendmail_qwriter.rb, line 4 def initialize initialize_id_array initialize_time end
Private Instance Methods
build_id(file_type)
click to toggle source
# File lib/sendmail_qwriter.rb, line 38 def build_id(file_type) # Build Queue ID for filenames priority = 'AA' id = '' id += "#{file_type}f" id += encode((@time.year - 1900)%60) id += encode(@time.month) id += encode(@time.day) id += encode(@time.hour) id += encode(@time.min) id += encode(@time.sec) id += encode(rand(@id_array.length)) id += priority id += Process.pid.to_s.rjust(5, '0') end
encode(value)
click to toggle source
# File lib/sendmail_qwriter.rb, line 31 def encode(value) # Encode value using encoding array @id_array[value].to_s end
initialize_id_array()
click to toggle source
# File lib/sendmail_qwriter.rb, line 13 def initialize_id_array # Build encoding array # 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz @id_array = [] @id_array += (0..9).to_a @id_array += ('A'..'Z').to_a @id_array += ('a'..'z').to_a end
initialize_time()
click to toggle source
# File lib/sendmail_qwriter.rb, line 24 def initialize_time # Initialize current timestamp variable @time = Time.now end