跳至内容 跳至搜索
方法
B
E

实例公共方法

blank?()

如果Pathname为空,则为空

Pathname.new("").blank?      # => true
Pathname.new(" ").blank?     # => false
Pathname.new("test").blank?  # => false

@return [true, false]

# File activesupport/lib/active_support/core_ext/pathname/blank.rb, line 13
def blank?
  to_s.empty?
end

existence()

如果指定的文件存在,则返回接收器,否则返回nilpathname.existence等同于

pathname.exist? ? pathname : nil

例如,类似

content = pathname.read if pathname.exist?

变为

content = pathname.existence&.read

@return [Pathname]

# File activesupport/lib/active_support/core_ext/pathname/existence.rb, line 20
def existence
  self if exist?
end