Module: Utilities::Strings

Defined in:
lib/utilities/strings.rb

Class Method Summary collapse

Class Method Details

.generate_md5(text) ⇒ Object



22
23
24
25
# File 'lib/utilities/strings.rb', line 22

def self.generate_md5(text)
  return nil if text.blank?
  Digest::MD5.hexdigest(text.gsub(/\s*/, '').downcase)
end

.nil_squish_strip(string) ⇒ Object

Strips space both condenses space



13
14
15
16
17
18
19
# File 'lib/utilities/strings.rb', line 13

def self.nil_squish_strip(string)
  if !string.nil?
    string.squish!
    string = nil if string == ''
  end
  string
end

.nil_strip(string) ⇒ Object

Strips space, leaves internal widespace as is



4
5
6
7
8
9
10
# File 'lib/utilities/strings.rb', line 4

def self.nil_strip(string) # string should have content or be empty
  if !string.nil?
    string.strip!
    string = nil if string == ''
  end
  string
end