Class: At_email::Formatting

Inherits:
Object
  • Object
show all
Defined in:
lib/at_email.rb

Instance Method Summary collapse

Constructor Details

#initializeFormatting

Returns a new instance of Formatting.



184
185
# File 'lib/at_email.rb', line 184

def initialize
end

Instance Method Details

#get_hash(data, hash_length) ⇒ Object



187
188
189
190
191
192
193
194
195
196
197
# File 'lib/at_email.rb', line 187

def get_hash(data, hash_length)
  if !hash_length.is_a? Numeric
    $logger.event('FATAL', 'FATAL ERROR', 'hash_length variable is not numeric')
    return false
  end
  if (hash_length > 32)
    $logger.event('FATAL', 'FATAL ERROR', 'hash_length maximum limit is 32 - Requested length: ' + hash_length.to_s)
    return false
  end
  return Digest::MD5.hexdigest(data)[0...hash_length]
end

#get_random_id(id_length) ⇒ Object



199
200
201
202
203
204
205
206
# File 'lib/at_email.rb', line 199

def get_random_id(id_length)
  hash = get_hash(Time.now.to_f.to_s + '-' + rand(1..1000000000000).to_s, id_length)
  if hash
    return hash
  else
    return false
  end
end