Sha256: 8439c97a3c873bc33c829f5d66da2947557433ecd4cf100d083250bc89b8114c

Contents?: true

Size: 456 Bytes

Versions: 45

Compression:

Stored size: 456 Bytes

Contents

# frozen_string_literal: true

require "pathname"

class Pathname
  # Returns the receiver if the named file exists otherwise returns +nil+.
  # <tt>pathname.existence</tt> is equivalent to
  #
  #    pathname.exist? ? pathname : nil
  #
  # For example, something like
  #
  #   content = pathname.read if pathname.exist?
  #
  # becomes
  #
  #   content = pathname.existence&.read
  #
  # @return [Pathname]
  def existence
    self if exist?
  end
end

Version data entries

45 entries across 45 versions & 8 rubygems

Version Path
activesupport-8.0.2 lib/active_support/core_ext/pathname/existence.rb
tailscale_middleware-0.0.3 vendor/cache/ruby/3.4.0/gems/activesupport-8.0.1/lib/active_support/core_ext/pathname/existence.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/activesupport-7.1.3.4/lib/active_support/core_ext/pathname/existence.rb
activesupport-8.0.1 lib/active_support/core_ext/pathname/existence.rb
activesupport-8.0.0.1 lib/active_support/core_ext/pathname/existence.rb
activesupport-7.2.2.1 lib/active_support/core_ext/pathname/existence.rb
activesupport-7.1.5.1 lib/active_support/core_ext/pathname/existence.rb
activesupport-8.0.0 lib/active_support/core_ext/pathname/existence.rb
activesupport-7.2.2 lib/active_support/core_ext/pathname/existence.rb
activesupport-7.1.5 lib/active_support/core_ext/pathname/existence.rb
activesupport-8.0.0.rc2 lib/active_support/core_ext/pathname/existence.rb
activesupport-7.2.1.2 lib/active_support/core_ext/pathname/existence.rb
activesupport-7.1.4.2 lib/active_support/core_ext/pathname/existence.rb
activesupport-8.0.0.rc1 lib/active_support/core_ext/pathname/existence.rb
activesupport-7.2.1.1 lib/active_support/core_ext/pathname/existence.rb
activesupport-7.1.4.1 lib/active_support/core_ext/pathname/existence.rb
activesupport-8.0.0.beta1 lib/active_support/core_ext/pathname/existence.rb
omg-activesupport-8.0.0.alpha9 lib/active_support/core_ext/pathname/existence.rb
omg-activesupport-8.0.0.alpha8 lib/active_support/core_ext/pathname/existence.rb
omg-activesupport-8.0.0.alpha7 lib/active_support/core_ext/pathname/existence.rb