Class: String

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

Overview

Monkey patch string with some useful methods

Instance Method Summary collapse

Instance Method Details

#to_asciiObject

Convert the string to ascii, stripping out or converting all non-ascii characters



26
27
28
29
30
31
32
33
34
# File 'lib/nub/string.rb', line 26

def to_ascii
  options = {
    :invalid => :replace,
    :undef => :replace,
    :replace => '',
    :universal_newline => true
  }
  return self.encode(Encoding.find('ASCII'), options)
end