Sha256: 622594d9b35fac679f6daa70a1edd292b4ffd135c566c18992494452e13f930d

Contents?: true

Size: 658 Bytes

Versions: 1

Compression:

Stored size: 658 Bytes

Contents

class String
  
  def remove_whitespace
    self.gsub(" ","")
  end
  
  def is_i?
    !!(self =~ /^[-+]?[0-9]([0-9]*)?$/)
  end
  
  #
  # Removes starting, trailing whitespace and double spaces
  #
  def trim
    self.gsub(/^(.*[^\s])\s+$/, '\1').gsub(/^\s*(.*)$/, '\1')
  end
  
  def to_utf16le
    Iconv.conv('utf-16le', 'UTF-8', self)
  end
  
  def to_active_record_condition
    "%#{self.trim.gsub(/[[:space:]]+/, '%')}%"
  end  
 
  def blank?
	  self !~ /\S/
    rescue ArgumentError => e
      if e.message =~ /^(invalid\ byte\ sequence|incompatible\ character\ encodings)/
	      empty?
      else
	      raise e
      end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
itrigga-core_ext-0.3.0 lib/itrigga/core_ext/string.rb