Module: Dropbox::API::Util

Defined in:
lib/dropbox-api/util/util.rb

Class Method Summary collapse

Class Method Details

.escape(string) ⇒ Object



8
9
10
11
12
# File 'lib/dropbox-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/dropbox-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



18
19
20
# File 'lib/dropbox-api/util/util.rb', line 18

def remove_double_slashes(path)
  path.gsub('//', '/')
end