Created
December 29, 2010 20:30
-
-
Save tjbladez/759031 to your computer and use it in GitHub Desktop.
pathname
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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