Skip to content

Instantly share code, notes, and snippets.

@tjbladez
Created December 29, 2010 20:30
Show Gist options
  • Save tjbladez/759031 to your computer and use it in GitHub Desktop.
Save tjbladez/759031 to your computer and use it in GitHub Desktop.
pathname
require 'pathname'
path = Pathname.new('.') # current directory
path += 'tests' # ./tests
path += 'functional' # ./tests/functional
path = path.parent # ./tests
path += 'config.yaml' # ./tests/config.yaml
path.read # contents of ./tests/config.yaml
path.open('w'){|io| io << "env: test"}
path.read # "env: test"
path.children{|p| puts p.inspect} # prints all the files/directories in ./tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment