Module: WriteMkpathExtension Private

Extended by:
T::Helpers
Defined in:
extend/pathname/write_mkpath_extension.rb

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Instance Method Summary collapse

Instance Method Details

#write(content, offset = T.unsafe(nil), external_encoding: T.unsafe(nil), internal_encoding: T.unsafe(nil), encoding: T.unsafe(nil), textmode: T.unsafe(nil), binmode: T.unsafe(nil), autoclose: T.unsafe(nil), mode: T.unsafe(nil), perm: T.unsafe(nil)) ⇒ Integer

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Source for sig: https://github.com/sorbet/sorbet/blob/b4092efe0a4489c28aff7e1ead6ee8a0179dc8b3/rbi/stdlib/pathname.rbi#L1392-L1411

Parameters:

  • content (Object)
  • offset (Integer) (defaults to: T.unsafe(nil))
  • external_encoding (String, Encoding) (defaults to: T.unsafe(nil))
  • internal_encoding (String, Encoding) (defaults to: T.unsafe(nil))
  • encoding (String, Encoding) (defaults to: T.unsafe(nil))
  • textmode (BasicObject) (defaults to: T.unsafe(nil))
  • binmode (BasicObject) (defaults to: T.unsafe(nil))
  • autoclose (BasicObject) (defaults to: T.unsafe(nil))
  • mode (String) (defaults to: T.unsafe(nil))
  • perm (Integer) (defaults to: T.unsafe(nil))

Returns:

  • (Integer)


24
25
26
27
28
29
30
31
32
33
# File 'extend/pathname/write_mkpath_extension.rb', line 24

def write(content, offset = T.unsafe(nil), external_encoding: T.unsafe(nil), internal_encoding: T.unsafe(nil),
          encoding: T.unsafe(nil), textmode: T.unsafe(nil), binmode: T.unsafe(nil), autoclose: T.unsafe(nil),
          mode: T.unsafe(nil), perm: T.unsafe(nil))
  T.bind(self, Pathname)
  raise "Will not overwrite #{self}" if exist? && !offset && !mode&.match?(/^a\+?$/)

  dirname.mkpath

  super
end