Class: String

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

Instance Method Summary collapse

Instance Method Details

#strip_htmlObject



2
3
4
# File 'lib/address_standardization/ruby_ext.rb', line 2

def strip_html
  gsub(/<\/?([^>]+)>/, '')
end

#strip_newlinesObject



5
6
7
# File 'lib/address_standardization/ruby_ext.rb', line 5

def strip_newlines
  gsub(/[\r\n]+/, '')
end

#strip_whitespaceObject



8
9
10
# File 'lib/address_standardization/ruby_ext.rb', line 8

def strip_whitespace
  strip_newlines.squeeze(" ").strip
end

#url_escapeObject



12
13
14
15
16
# File 'lib/address_standardization/ruby_ext.rb', line 12

def url_escape
  gsub(/([^ a-zA-Z0-9_.-]+)/n) do
    '%' + $1.unpack('H2' * $1.size).join('%').upcase
  end.tr(' ', '+')
end