URI::File 类
RFC8089 定义了 “file” URI。
Constants
Public Class Methods
Source
# 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::RFC2396_PARSER.escape('/path/my file.txt')}) uri3.to_s # => "file:///path/my%20file.txt"
调用超类方法
Public Instance Methods
Source
# File lib/uri/file.rb, line 82 def check_password(user) raise URI::InvalidURIError, "cannot set password for file URI" end
Source
# File lib/uri/file.rb, line 77 def check_user(user) raise URI::InvalidURIError, "cannot set user for file URI" end
Source
# File lib/uri/file.rb, line 72 def check_userinfo(user) raise URI::InvalidURIError, "cannot set userinfo for file URI" end
Source
# File lib/uri/file.rb, line 62 def set_host(v) v = "" if v.nil? || v == "localhost" @host = v end
用于主机组件 v 的受保护的设置器。
另请参阅 URI::Generic.host=。