class Egnyte::Helper

Public Class Methods

encode_url(url) click to toggle source
# File lib/egnyte/helper.rb, line 36
def self.encode_url(url)
  URI.encode(url).gsub("[","%5B").gsub("]","%5D")
end
normalize_path(path) click to toggle source

removes leading and trailing '/' from folder and file names.

# File lib/egnyte/helper.rb, line 6
def self.normalize_path(path)
  path.gsub(/(^\/)|(\/$)/, '')
end
params_to_filter_string(params) click to toggle source
# File lib/egnyte/helper.rb, line 23
def self.params_to_filter_string(params)
  str = ''
  if params
    str = "?"
    params.each_with_index do |(k,v),i|
      str += "filter="
      str += "#{k} eq \"#{v}\""
      str += "&" unless i == params.size - 1
    end
  end
  return str
end
params_to_s(params) click to toggle source
# File lib/egnyte/helper.rb, line 10
def self.params_to_s(params)
  str = ''
  if params
    str = "?"
    params.each_with_index do |(k,v),i|
      v.split('|') if v.instance_of? Array
      str += "#{k}=#{v}"
      str += "&" unless i == params.size - 1
    end
  end
  return str
end