Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/address_standardization/ruby_ext.rb
Instance Method Summary collapse
Instance Method Details
#strip_html ⇒ Object
2 3 4 |
# File 'lib/address_standardization/ruby_ext.rb', line 2 def strip_html gsub(/<\/?([^>]+)>/, '') end |
#strip_newlines ⇒ Object
5 6 7 |
# File 'lib/address_standardization/ruby_ext.rb', line 5 def strip_newlines gsub(/[\r\n]+/, '') end |
#strip_whitespace ⇒ Object
8 9 10 |
# File 'lib/address_standardization/ruby_ext.rb', line 8 def strip_whitespace strip_newlines.squeeze(" ").strip end |
#url_escape ⇒ Object
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 |