instance method
URI::Generic#fragment=
(::String? v) -> ::String?
fragment=(v)
lib/uri/generic.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/uri/generic.rb, line 944
def fragment=(v)
return @fragment = nil unless v
x = v.to_str
v = x.dup if x.equal? v
v.encode!(Encoding::UTF_8) rescue nil
v.delete!("\t\r\n")
v.force_encoding(Encoding::ASCII_8BIT)
v.gsub!(/(?!%\h\h|[!-~])./n){'%%%02X' % $&.ord}
v.force_encoding(Encoding::US_ASCII)
@fragment = v
end
Checks the fragment v component against the parser Regexp for :FRAGMENT.
Args
v
Description
Public setter for the fragment component v (with validation).
Usage
Example
require 'uri' uri = URI.parse("http://my.example.com/?id=25#time=1305212049") uri.fragment = "time=1305212086" uri.to_s #=> "http://my.example.com/?id=25#time=1305212086"
See also
#find_proxy
#hash
#escape_userpass
#hierarchical?
also in
4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0