@@ -150,6 +150,7 @@ module ::Kernel
150150# - #read(*args)
151151# - #binread(*args)
152152# - #readlines(*args)
153+ # - #sysopen(*args)
153154# - #write(*args)
154155# - #binwrite(*args)
155156# - #atime
@@ -190,11 +191,6 @@ module ::Kernel
190191# - #mkdir(*args)
191192# - #opendir(*args)
192193#
193- # === IO
194- #
195- # This method is a facade for IO:
196- # - #sysopen(*args)
197- #
198194# === Utilities
199195#
200196# These methods are a mixture of Find, FileUtils, and others:
@@ -239,9 +235,10 @@ class Pathname
239235 # If +path+ contains a NUL character (<tt>\0</tt>), an ArgumentError is raised.
240236 #
241237 def initialize ( path )
242- path = path . to_path if path . respond_to? :to_path
243-
244- raise TypeError unless path . is_a? ( String ) # Compatibility for C version
238+ unless String === path
239+ path = path . to_path if path . respond_to? :to_path
240+ raise TypeError unless String === path
241+ end
245242
246243 if path . include? ( "\0 " )
247244 raise ArgumentError , "pathname contains \\ 0: #{ path . inspect } "
@@ -884,11 +881,6 @@ def relative_path_from(base_directory)
884881 end
885882end
886883
887- class Pathname # * IO *
888- # See <tt>IO.sysopen</tt>.
889- def sysopen ( ...) IO . sysopen ( @path , ...) end
890- end
891-
892884class Pathname # * File *
893885 #
894886 # #each_line iterates over the line in the file. It yields a String object
@@ -911,6 +903,9 @@ def binread(...) File.binread(@path, ...) end
911903 # See <tt>File.readlines</tt>. Returns all the lines from the file.
912904 def readlines ( ...) File . readlines ( @path , ...) end
913905
906+ # See <tt>File.sysopen</tt>.
907+ def sysopen ( ...) File . sysopen ( @path , ...) end
908+
914909 # Writes +contents+ to the file. See <tt>File.write</tt>.
915910 def write ( ...) File . write ( @path , ...) end
916911
@@ -986,6 +981,13 @@ def truncate(length) File.truncate(@path, length) end
986981 # See <tt>File.utime</tt>. Update the access and modification times.
987982 def utime ( atime , mtime ) File . utime ( atime , mtime , @path ) end
988983
984+ # Update the access and modification times of the file.
985+ #
986+ # Same as Pathname#utime, but does not follow symbolic links.
987+ #
988+ # See File.lutime.
989+ def lutime ( atime , mtime ) File . lutime ( atime , mtime , @path ) end
990+
989991 # See <tt>File.basename</tt>. Returns the last component of the path.
990992 def basename ( ...) self . class . new ( File . basename ( @path , ...) ) end
991993
@@ -1012,6 +1014,13 @@ def split()
10121014 #
10131015 # All components of the pathname must exist when this method is called.
10141016 def realpath ( ...) self . class . new ( File . realpath ( @path , ...) ) end
1017+
1018+ # Returns the real (absolute) pathname of +self+ in the actual filesystem.
1019+ #
1020+ # Does not contain symlinks or useless dots, +..+ and +.+.
1021+ #
1022+ # The last component of the real pathname can be nonexistent.
1023+ def realdirpath ( ...) self . class . new ( File . realdirpath ( @path , ...) ) end
10151024end
10161025
10171026
@@ -1236,12 +1245,8 @@ module Kernel
12361245 #
12371246 # This method is available since 1.8.5.
12381247 def Pathname ( path ) # :doc:
1239- Kernel . Pathname ( path )
1240- end
1241- private :Pathname
1242-
1243- def self . Pathname ( path ) # Compatibility for C version
12441248 return path if Pathname === path
12451249 Pathname . new ( path )
12461250 end
1251+ module_function :Pathname
12471252end
0 commit comments