instance method
existence
Ruby on Rails edge
Since v7.0.10Signature
existence()
Returns the receiver if the named file exists; otherwise, returns nil. pathname.existence is equivalent to:
“‘ruby pathname.exist? ? pathname : nil “`
For example, this:
“‘ruby content = pathname.read if pathname.exist? “`
becomes:
“‘ruby content = pathname.existence&.read “`
@return [Pathname]
Source
# File activesupport/lib/active_support/core_ext/pathname/existence.rb, line 26
def existence
self if exist?
end
Defined in activesupport/lib/active_support/core_ext/pathname/existence.rb line 26
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Pathname