本文简要介绍ruby语言中 Pathname.children 的用法。
用法
children(with_directory=true)
以 Pathname 对象数组的形式返回目录的子项(文件和子目录,非递归)。
默认情况下,返回的路径名将有足够的信息来访问文件。如果将 with_directory 设置为 false ,则返回的路径名将仅包含文件名。
例如:
pn = Pathname("/usr/lib/ruby/1.8")
pn.children
# -> [ Pathname:/usr/lib/ruby/1.8/English.rb,
Pathname:/usr/lib/ruby/1.8/Env.rb,
Pathname:/usr/lib/ruby/1.8/abbrev.rb, ... ]
pn.children(false)
# -> [ Pathname:English.rb, Pathname:Env.rb, Pathname:abbrev.rb, ... ]
请注意,结果从不包含目录中的条目. 和..,因为它们不是子项。
相关用法
- Ruby Pathname.<=>用法及代码示例
- Ruby Pathname.descend用法及代码示例
- Ruby Pathname.getwd用法及代码示例
- Ruby Pathname.ascend用法及代码示例
- Ruby Pathname.pwd用法及代码示例
- Ruby Pathname.+用法及代码示例
- Ruby Pathname.sub_ext用法及代码示例
- Ruby Pathname.glob用法及代码示例
- Ruby Pathname.entries用法及代码示例
- Ruby Pathname.join用法及代码示例
- Ruby Pathname.sub用法及代码示例
- Ruby Pathname.each_filename用法及代码示例
- Ruby Pathname.absolute?用法及代码示例
- Ruby Pathname.relative?用法及代码示例
- Ruby Pathname.each_child用法及代码示例
- Ruby Pathname类用法及代码示例
- Ruby Parser类用法及代码示例
- Ruby Parser.use_markup用法及代码示例
- Ruby PackageTask类用法及代码示例
- Ruby PrettyPrint.current_group用法及代码示例
- Ruby Process.groups用法及代码示例
- Ruby Process.wait2用法及代码示例
- Ruby Process.getpgrp用法及代码示例
- Ruby Proc.eql?用法及代码示例
- Ruby PTY.open用法及代码示例
注:本文由纯净天空筛选整理自ruby-lang.org大神的英文原创作品 Pathname.children。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
