Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

書籍 Ruby Cookbook | ツリーの作成

パンくず

Ruby Cookbook
ツリーの作成

概要

ツリーの作成

内容

カレント配下のファイル、フォルダを取り扱うにはFindクラスのfindメソッド
利用します。

サンプルコード

# encoding: Windows-31J
require 'find'

Find.find('./').each do |file|
  puts file
end

出力

./
./1_.rb
./1_ファイルの存在確認.txt
./2_.rb
./2_パーミッションの確認.txt
./3_.rb
./3_最終更新日の取得.txt
./4_.rb
./4_ツリーの作成.txt
./hoge
./hoge/hoge
./hoge/hoge/hoge.txt
./hoge/hoge.txt
./memo.txt