方法
实例公共方法
blank?() 链接
如果Pathname
为空,则为空
Pathname.new("").blank? # => true
Pathname.new(" ").blank? # => false
Pathname.new("test").blank? # => false
@return [true, false]
来源:显示 | 在 GitHub 上
# File activesupport/lib/active_support/core_ext/pathname/blank.rb, line 13 def blank? to_s.empty? end
existence() 链接
如果指定的文件存在,则返回接收器,否则返回nil
。pathname.existence
等同于
pathname.exist? ? pathname : nil
例如,类似
content = pathname.read if pathname.exist?
变为
content = pathname.existence&.read
@return [Pathname]
来源:显示 | 在 GitHub 上
# File activesupport/lib/active_support/core_ext/pathname/existence.rb, line 20 def existence self if exist? end