Skip to content

Instantly share code, notes, and snippets.

@awesome
Last active March 22, 2017 04:38
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 awesome/c642dd70a0dab163321bda5a1596325d to your computer and use it in GitHub Desktop.
Save awesome/c642dd70a0dab163321bda5a1596325d to your computer and use it in GitHub Desktop.
# irb(main):011:0> File.expand_path(File.dirname(__FILE__))
# => "/Users/dev/Documents/Bordee/repo/svelte-ruby"
# irb(main):012:0> File.dirname(File.expand_path(__FILE__))
# => "/Users/dev/Documents/Bordee/repo/svelte-ruby"
# irb(main):012:0> File.expand_path('..', __FILE__)
# => "/Users/dev/Documents/Bordee/repo/svelte-ruby"
# right? so let's do this lol
module FileExt
def self.expand_dir(string)
case rand(3)
when 0
::File.expand_path(File.dirname(string))
when 1
::File.dirname(File.expand_path(string))
else # 3
::File.expand_path('..', string)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment