Class: URI::CoreFile

Inherits:
Generic
  • Object
show all
Includes:
FileCommon
Defined in:
lib/file-uri.rb

Constant Summary

Constants included from FileCommon

FileCommon::BACKSLASH, FileCommon::COLON, FileCommon::COMPONENT, FileCommon::DBL_BACKSLASH, FileCommon::DBL_SLASH, FileCommon::LOCALHOST, FileCommon::SLASH

Instance Method Summary collapse

Methods included from FileCommon

build, #local?, #open, #to_file_path, #to_unc

Constructor Details

#initialize(scheme, userinfo, host, port, registry, path, opaque, query, fragment, parser = DEFAULT_PARSER, arg_check = false) ⇒ CoreFile

Returns a new instance of CoreFile.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/file-uri.rb', line 8

def initialize(scheme,
               userinfo, host, port, registry,
               path, opaque,
               query,
               fragment,
               parser = DEFAULT_PARSER,
               arg_check = false)
  # detect UNC-type paths ("file:////server/Share/dir/file.ext")
  if !host && path && path =~ %r[\A//+]
    path = path.sub(%r[\A/+], DBL_SLASH)
    host = ''
  # ...urgh
  elsif path && path =~ %r[\A/+]
    path = path.sub(%r[\A/+], SLASH)
  end
  super(scheme, userinfo, host, port, registry, path, opaque, query, fragment, parser, arg_check)
end