Class: Pathname

Inherits:
Object show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/core_ext/object/json.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/core_ext/pathname/existence.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#as_json(options = nil) ⇒ Object



223
224
225
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/core_ext/object/json.rb', line 223

def as_json(options = nil)
  to_s
end

#existencePathname

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

Returns:



18
19
20
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/core_ext/pathname/existence.rb', line 18

def existence
  self if exist?
end