Skip to content

Commit 8f582dc

Browse files
committed
Use File.path for conversion to path name
This method has been defined since 1.9, as the standard conversion procedure.
1 parent 95ad4ce commit 8f582dc

1 file changed

Lines changed: 1 addition & 11 deletions

File tree

lib/pathname_builtin.rb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -212,17 +212,7 @@ class Pathname
212212
# If +path+ contains a NUL character (<tt>\0</tt>), an ArgumentError is raised.
213213
#
214214
def initialize(path)
215-
unless String === path
216-
path = path.to_path if path.respond_to? :to_path
217-
path = path.to_str if path.respond_to? :to_str
218-
raise TypeError, "Pathname.new requires a String, #to_path or #to_str" unless String === path
219-
end
220-
221-
if path.include?("\0")
222-
raise ArgumentError, "pathname contains \\0: #{path.inspect}"
223-
end
224-
225-
@path = path.dup
215+
@path = File.path(path).dup
226216
end
227217

228218
def freeze

0 commit comments

Comments
 (0)