Sha256: 2a58e3279876ba018c1ab0e51b866be0f00ff1f7bee5c6ca184031f92ddb9e64

Contents?: true

Size: 436 Bytes

Versions: 41

Compression:

Stored size: 436 Bytes

Contents

# frozen_string_literal: true

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

41 entries across 38 versions & 8 rubygems

Version Path
activesupport-7.0.8.6 lib/active_support/core_ext/pathname/existence.rb
activesupport-7.0.8.5 lib/active_support/core_ext/pathname/existence.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.8.4/lib/active_support/core_ext/pathname/existence.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/activesupport-7.0.5.1/lib/active_support/core_ext/pathname/existence.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/activesupport-7.0.5.1/lib/active_support/core_ext/pathname/existence.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/activesupport-7.0.5.1/lib/active_support/core_ext/pathname/existence.rb
activesupport-7.0.8.4 lib/active_support/core_ext/pathname/existence.rb
activesupport-7.0.8.1 lib/active_support/core_ext/pathname/existence.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activesupport-7.0.2.3/lib/active_support/core_ext/pathname/existence.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activesupport-7.0.3.1/lib/active_support/core_ext/pathname/existence.rb
activesupport-7.0.8 lib/active_support/core_ext/pathname/existence.rb
activesupport-7.0.7.2 lib/active_support/core_ext/pathname/existence.rb
activesupport-7.0.7.1 lib/active_support/core_ext/pathname/existence.rb
activesupport-7.0.7 lib/active_support/core_ext/pathname/existence.rb
mlh-rubocop-config-1.0.2 vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/core_ext/pathname/existence.rb
fablicop-1.10.3 vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.5/lib/active_support/core_ext/pathname/existence.rb
fablicop-1.10.3 vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/core_ext/pathname/existence.rb
activesupport-7.0.6 lib/active_support/core_ext/pathname/existence.rb
activesupport-7.0.5.1 lib/active_support/core_ext/pathname/existence.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/activesupport-7.0.3.1/lib/active_support/core_ext/pathname/existence.rb