require 'pathname'
pathname = Pathname.new '/home/james/learning/ruby/fun/today.txt'
#=> #
pathname.exist?
#=> false
pathname.basename
#=> #
#=> #
pathname.dirname.mkdir
#=> 0
# observed directory '/home/james/learning/ruby/fun' was just created
1) There is no Pathname#mkdir_p meaning parent directories will not be created automatically.
2) If the directory to be created already exists it will create an error
e.g. Errno::EEXIST: File exists - /home/james/learning/ruby/fun
Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/22zLf6bnb_M/11643