Pathname
require 'pathname'
path = Pathname.new('.') # current directory
path += 'lib' # ./lib
path += 'actors' # ./lib/actors
path = path.parent # ./lib
path += 'director.rb' # ./lib/director.rb
path.read # contents of ./lib/director.rb
path.open('w'){|io| io << "something"}
path.read # "something"
path.children{|p| puts p.inspect} # prints all the files/directories in ./lib
Written by Nickolay Schwarz
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#