Module: Cloudpt::API::Util
- Defined in:
- lib/cloudpt-api/util/util.rb
Class Method Summary collapse
- .escape(string) ⇒ Object
- .query(data) ⇒ Object
- .remove_double_slashes(path) ⇒ Object
- .strip_slash(path) ⇒ Object
Class Method Details
.escape(string) ⇒ Object
8 9 10 11 12 |
# File 'lib/cloudpt-api/util/util.rb', line 8 def escape(string) string.gsub(/([^ a-zA-Z0-9\.\\\-\/\_]+)/) do '%' + $1.unpack('H2' * $1.bytesize).join('%').upcase end.gsub(' ', '%20') end |
.query(data) ⇒ Object
14 15 16 |
# File 'lib/cloudpt-api/util/util.rb', line 14 def query(data) data.inject([]) { |memo, entry| memo.push(entry.join('=')); memo }.join('&') end |
.remove_double_slashes(path) ⇒ Object
22 23 24 |
# File 'lib/cloudpt-api/util/util.rb', line 22 def remove_double_slashes(path) path.gsub('//', '/') end |
.strip_slash(path) ⇒ Object
18 19 20 |
# File 'lib/cloudpt-api/util/util.rb', line 18 def strip_slash(path) path.sub(/^\//, '') end |