Skip to content

Instantly share code, notes, and snippets.

@garyharan
Created April 6, 2011 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garyharan/904914 to your computer and use it in GitHub Desktop.
Save garyharan/904914 to your computer and use it in GitHub Desktop.
fudging args
#!/usr/bin/ruby
require 'net/http'
def url(*args)
if args.length == 1
"/#{1}/#{args[0]}.json"
else
"/#{1}/#{args.shift.to_s}.json?#{parametrize args}"
end
end
def get(*args)
puts url(*args)
end
def parametrize(options)
URI.escape(options.collect do |k,v|
v = v.to_i if k == :since
v = v.join(',') if v.instance_of?(Array)
k = k.to_s.gsub('_', '')
"#{k}=#{v}"
end.to_a.join('&'))
end
get 'imap/removeaccount', :first => 'string', :second => 'string', :third => 'string'
get 'imap/fuckthisaccount'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment