Reduce number of string operations

Once Ruby 1.8.7 reaches end-of-life, we can remove the tr entirely by
using Base64.urlsafe_encode and -_decode (which are implemented in the
standard library by using tr in exactly this way).
Use module_function to reduce 'def self.'
Be consistent with quoting
Swap branches to reduce negation
Source :rubygems is deprecated
Merge pull request #20 from threedaymonk/tweaks

Tweaks and improvements