Methods

Instance Public methods

blank?()

An Pathname is blank if it’s empty:

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

@return [true, false]

πŸ“ Source code
# File activesupport/lib/active_support/core_ext/pathname/blank.rb, line 13
  def blank?
    to_s.empty?
  end
πŸ”Ž See on GitHub

existence()

Returns the receiver if the named file exists otherwise returns nil. pathname.existence is equivalent to

pathname.exist? ? pathname : nil

For example, something like

content = pathname.read if pathname.exist?

becomes

content = pathname.existence&.read

@return [Pathname]

πŸ“ Source code
# File activesupport/lib/active_support/core_ext/pathname/existence.rb, line 20
  def existence
    self if exist?
  end
πŸ”Ž See on GitHub