class URI::File
“file” URI
由 RFC8089 定义。
常量
公共类方法
源代码
# File lib/uri/file.rb, line 53 def self.build(args) tmp = Util::make_components_hash(self, args) super(tmp) end
描述¶ ↑
从组件创建新的 URI::File
对象,并进行语法检查。
接受的组件是 host
和 path
。
组件应以 Array
的形式提供,或者以键是通过在组件名称前加冒号形成的 Hash
的形式提供。
如果使用 Array
,则组件必须按 [host, path]
的顺序传递。
来自例如 File
类的路径应在传递之前进行转义。
示例
require 'uri' uri1 = URI::File.build(['host.example.com', '/path/file.zip']) uri1.to_s # => "file://host.example.com/path/file.zip" uri2 = URI::File.build({:host => 'host.example.com', :path => '/ruby/src'}) uri2.to_s # => "file://host.example.com/ruby/src" uri3 = URI::File.build({:path => URI::escape('/path/my file.txt')}) uri3.to_s # => "file:///path/my%20file.txt"
调用父类方法
公共实例方法
源代码
# File lib/uri/file.rb, line 82 def check_password(user) raise URI::InvalidURIError, "cannot set password for file URI" end
源代码
# File lib/uri/file.rb, line 77 def check_user(user) raise URI::InvalidURIError, "cannot set user for file URI" end
源代码
# File lib/uri/file.rb, line 72 def check_userinfo(user) raise URI::InvalidURIError, "cannot set userinfo for file URI" end
源代码
# File lib/uri/file.rb, line 62 def set_host(v) v = "" if v.nil? || v == "localhost" @host = v end
主机组件 v
的受保护的设置器。
另请参见 URI::Generic.host=
。