rbs 0.10.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +9 -9
  3. data/CHANGELOG.md +29 -0
  4. data/Gemfile +1 -0
  5. data/README.md +1 -1
  6. data/Rakefile +16 -6
  7. data/Steepfile +28 -0
  8. data/bin/steep +4 -0
  9. data/bin/test_runner.rb +7 -5
  10. data/docs/syntax.md +14 -1
  11. data/lib/rbs/ast/comment.rb +7 -1
  12. data/lib/rbs/ast/declarations.rb +15 -9
  13. data/lib/rbs/ast/members.rb +3 -8
  14. data/lib/rbs/buffer.rb +1 -1
  15. data/lib/rbs/cli.rb +72 -3
  16. data/lib/rbs/constant.rb +1 -1
  17. data/lib/rbs/constant_table.rb +9 -8
  18. data/lib/rbs/definition.rb +31 -14
  19. data/lib/rbs/definition_builder.rb +97 -67
  20. data/lib/rbs/environment.rb +28 -11
  21. data/lib/rbs/environment_loader.rb +67 -47
  22. data/lib/rbs/location.rb +1 -5
  23. data/lib/rbs/method_type.rb +5 -5
  24. data/lib/rbs/namespace.rb +14 -3
  25. data/lib/rbs/parser.y +2 -12
  26. data/lib/rbs/prototype/rb.rb +3 -5
  27. data/lib/rbs/prototype/rbi.rb +1 -4
  28. data/lib/rbs/prototype/runtime.rb +0 -4
  29. data/lib/rbs/substitution.rb +4 -3
  30. data/lib/rbs/test/setup.rb +5 -1
  31. data/lib/rbs/test/setup_helper.rb +15 -0
  32. data/lib/rbs/test/tester.rb +7 -5
  33. data/lib/rbs/test/type_check.rb +14 -2
  34. data/lib/rbs/type_name.rb +18 -1
  35. data/lib/rbs/type_name_resolver.rb +10 -3
  36. data/lib/rbs/types.rb +27 -21
  37. data/lib/rbs/variance_calculator.rb +9 -6
  38. data/lib/rbs/version.rb +1 -1
  39. data/lib/rbs/writer.rb +26 -17
  40. data/sig/annotation.rbs +26 -0
  41. data/sig/buffer.rbs +28 -0
  42. data/sig/builtin_names.rbs +41 -0
  43. data/sig/comment.rbs +26 -0
  44. data/sig/constant.rbs +21 -0
  45. data/sig/constant_table.rbs +30 -0
  46. data/sig/declarations.rbs +202 -0
  47. data/sig/definition.rbs +129 -0
  48. data/sig/definition_builder.rbs +94 -0
  49. data/sig/environment.rbs +94 -0
  50. data/sig/environment_loader.rbs +58 -0
  51. data/sig/location.rbs +52 -0
  52. data/sig/members.rbs +160 -0
  53. data/sig/method_types.rbs +40 -0
  54. data/sig/namespace.rbs +124 -0
  55. data/sig/polyfill.rbs +3 -0
  56. data/sig/rbs.rbs +3 -0
  57. data/sig/substitution.rbs +39 -0
  58. data/sig/type_name_resolver.rbs +24 -0
  59. data/sig/typename.rbs +70 -0
  60. data/sig/types.rbs +361 -0
  61. data/sig/util.rbs +13 -0
  62. data/sig/variance_calculator.rbs +35 -0
  63. data/sig/version.rbs +3 -0
  64. data/sig/writer.rbs +40 -0
  65. data/stdlib/bigdecimal/big_decimal.rbs +887 -0
  66. data/stdlib/bigdecimal/math/big_math.rbs +142 -0
  67. data/stdlib/builtin/array.rbs +2 -1
  68. data/stdlib/builtin/builtin.rbs +0 -3
  69. data/stdlib/builtin/hash.rbs +1 -1
  70. data/stdlib/builtin/kernel.rbs +2 -0
  71. data/stdlib/builtin/math.rbs +26 -26
  72. data/stdlib/builtin/struct.rbs +9 -10
  73. data/stdlib/date/date.rbs +1056 -0
  74. data/stdlib/date/date_time.rbs +582 -0
  75. data/stdlib/forwardable/forwardable.rbs +204 -0
  76. data/stdlib/pathname/pathname.rbs +2 -0
  77. data/stdlib/pty/pty.rbs +5 -29
  78. data/stdlib/set/set.rbs +1 -1
  79. data/stdlib/uri/file.rbs +167 -0
  80. data/stdlib/uri/generic.rbs +875 -0
  81. data/stdlib/uri/http.rbs +158 -0
  82. data/stdlib/uri/https.rbs +108 -0
  83. data/stdlib/uri/ldap.rbs +224 -0
  84. data/stdlib/uri/ldaps.rbs +108 -0
  85. data/stdlib/zlib/zlib.rbs +1 -1
  86. data/steep/Gemfile +3 -0
  87. data/steep/Gemfile.lock +51 -0
  88. metadata +45 -5
@@ -0,0 +1,204 @@
1
+ # The Forwardable module provides delegation of specified methods to a
2
+ # designated object, using the methods #def_delegator and #def_delegators.
3
+ #
4
+ # For example, say you have a class RecordCollection which contains an array
5
+ # `@records`. You could provide the lookup method #record_number(), which
6
+ # simply calls #[] on the `@records` array, like this:
7
+ #
8
+ # require 'forwardable'
9
+ #
10
+ # class RecordCollection
11
+ # attr_accessor :records
12
+ # extend Forwardable
13
+ # def_delegator :@records, :[], :record_number
14
+ # end
15
+ #
16
+ # We can use the lookup method like so:
17
+ #
18
+ # r = RecordCollection.new
19
+ # r.records = [4,5,6]
20
+ # r.record_number(0) # => 4
21
+ #
22
+ # Further, if you wish to provide the methods #size, #<<, and #map, all of which
23
+ # delegate to @records, this is how you can do it:
24
+ #
25
+ # class RecordCollection # re-open RecordCollection class
26
+ # def_delegators :@records, :size, :<<, :map
27
+ # end
28
+ #
29
+ # r = RecordCollection.new
30
+ # r.records = [1,2,3]
31
+ # r.record_number(0) # => 1
32
+ # r.size # => 3
33
+ # r << 4 # => [1, 2, 3, 4]
34
+ # r.map { |x| x * 2 } # => [2, 4, 6, 8]
35
+ #
36
+ # You can even extend regular objects with Forwardable.
37
+ #
38
+ # my_hash = Hash.new
39
+ # my_hash.extend Forwardable # prepare object for delegation
40
+ # my_hash.def_delegator "STDOUT", "puts" # add delegation for STDOUT.puts()
41
+ # my_hash.puts "Howdy!"
42
+ #
43
+ # ## Another example
44
+ #
45
+ # You could use Forwardable as an alternative to inheritance, when you don't
46
+ # want to inherit all methods from the superclass. For instance, here is how you
47
+ # might add a range of `Array` instance methods to a new class `Queue`:
48
+ #
49
+ # class Queue
50
+ # extend Forwardable
51
+ #
52
+ # def initialize
53
+ # @q = [ ] # prepare delegate object
54
+ # end
55
+ #
56
+ # # setup preferred interface, enq() and deq()...
57
+ # def_delegator :@q, :push, :enq
58
+ # def_delegator :@q, :shift, :deq
59
+ #
60
+ # # support some general Array methods that fit Queues well
61
+ # def_delegators :@q, :clear, :first, :push, :shift, :size
62
+ # end
63
+ #
64
+ # q = Queue.new
65
+ # q.enq 1, 2, 3, 4, 5
66
+ # q.push 6
67
+ #
68
+ # q.shift # => 1
69
+ # while q.size > 0
70
+ # puts q.deq
71
+ # end
72
+ #
73
+ # q.enq "Ruby", "Perl", "Python"
74
+ # puts q.first
75
+ # q.clear
76
+ # puts q.first
77
+ #
78
+ # This should output:
79
+ #
80
+ # 2
81
+ # 3
82
+ # 4
83
+ # 5
84
+ # 6
85
+ # Ruby
86
+ # nil
87
+ #
88
+ # ## Notes
89
+ #
90
+ # Be advised, RDoc will not detect delegated methods.
91
+ #
92
+ # `forwardable.rb` provides single-method delegation via the def_delegator and
93
+ # def_delegators methods. For full-class delegation via DelegateClass, see
94
+ # `delegate.rb`.
95
+ #
96
+ module Forwardable
97
+ VERSION: String
98
+
99
+ FORWARDABLE_VERSION: String
100
+
101
+ # Takes a hash as its argument. The key is a symbol or an array of symbols.
102
+ # These symbols correspond to method names, instance variable names, or constant
103
+ # names (see def_delegator). The value is the accessor to which the methods
104
+ # will be delegated.
105
+ def instance_delegate: (Hash[Symbol | Array[Symbol], Symbol] hash) -> void
106
+
107
+ alias delegate instance_delegate
108
+
109
+ # Shortcut for defining multiple delegator methods, but with no provision for
110
+ # using a different name. The following two code samples have the same effect:
111
+ #
112
+ # def_delegators :@records, :size, :<<, :map
113
+ #
114
+ # def_delegator :@records, :size
115
+ # def_delegator :@records, :<<
116
+ # def_delegator :@records, :map
117
+ #
118
+ def def_instance_delegators: (Symbol | String accessor, *Symbol methods) -> void
119
+
120
+ alias def_delegators def_instance_delegators
121
+
122
+ # Define `method` as delegator instance method with an optional alias name
123
+ # `ali`. Method calls to `ali` will be delegated to `accessor.method`.
124
+ # `accessor` should be a method name, instance variable name, or constant name.
125
+ # Use the full path to the constant if providing the constant name. Returns the
126
+ # name of the method defined.
127
+ #
128
+ # class MyQueue
129
+ # CONST = 1
130
+ # extend Forwardable
131
+ # attr_reader :queue
132
+ # def initialize
133
+ # @queue = []
134
+ # end
135
+ #
136
+ # def_delegator :@queue, :push, :mypush
137
+ # def_delegator 'MyQueue::CONST', :to_i
138
+ # end
139
+ #
140
+ # q = MyQueue.new
141
+ # q.mypush 42
142
+ # q.queue #=> [42]
143
+ # q.push 23 #=> NoMethodError
144
+ # q.to_i #=> 1
145
+ #
146
+ def def_instance_delegator: (Symbol | String accessor, Symbol method, ?Symbol ali) -> void
147
+
148
+ alias def_delegator def_instance_delegator
149
+ end
150
+
151
+ # SingleForwardable can be used to setup delegation at the object level as well.
152
+ #
153
+ # printer = String.new
154
+ # printer.extend SingleForwardable # prepare object for delegation
155
+ # printer.def_delegator "STDOUT", "puts" # add delegation for STDOUT.puts()
156
+ # printer.puts "Howdy!"
157
+ #
158
+ # Also, SingleForwardable can be used to set up delegation for a Class or
159
+ # Module.
160
+ #
161
+ # class Implementation
162
+ # def self.service
163
+ # puts "serviced!"
164
+ # end
165
+ # end
166
+ #
167
+ # module Facade
168
+ # extend SingleForwardable
169
+ # def_delegator :Implementation, :service
170
+ # end
171
+ #
172
+ # Facade.service #=> serviced!
173
+ #
174
+ # If you want to use both Forwardable and SingleForwardable, you can use methods
175
+ # def_instance_delegator and def_single_delegator, etc.
176
+ #
177
+ module SingleForwardable
178
+ # Takes a hash as its argument. The key is a symbol or an array of symbols.
179
+ # These symbols correspond to method names. The value is the accessor to which
180
+ # the methods will be delegated.
181
+ def single_delegate: (Hash[Symbol | Array[Symbol], Symbol] hash) -> void
182
+
183
+ alias delegate single_delegate
184
+
185
+ # Shortcut for defining multiple delegator methods, but with no provision for
186
+ # using a different name. The following two code samples have the same effect:
187
+ #
188
+ # def_delegators :@records, :size, :<<, :map
189
+ #
190
+ # def_delegator :@records, :size
191
+ # def_delegator :@records, :<<
192
+ # def_delegator :@records, :map
193
+ #
194
+ def def_single_delegators: (Symbol | String accessor, *Symbol methods) -> void
195
+
196
+ alias def_delegators def_single_delegators
197
+
198
+ # Defines a method *method* which delegates to *accessor* (i.e. it calls the
199
+ # method of the same name in *accessor*). If *new_name* is provided, it is used
200
+ # as the name for the delegate method. Returns the name of the method defined.
201
+ def def_single_delegator: (Symbol | String accessor, Symbol method, ?Symbol ali) -> void
202
+
203
+ alias def_delegator def_single_delegator
204
+ end
@@ -1077,6 +1077,8 @@ class Pathname
1077
1077
  end
1078
1078
 
1079
1079
  module Kernel
1080
+ private
1081
+
1080
1082
  # Creates a new Pathname object from the given string, `path`, and returns
1081
1083
  # pathname object.
1082
1084
  #
@@ -65,34 +65,10 @@ module PTY
65
65
  # `raise`
66
66
  # : If `true` and the process identified by `pid` is no longer alive a
67
67
  # PTY::ChildExited is raised.
68
- def self.check: (Integer pid) -> (Process::Status | nil)
69
- | (Integer pid, FalseClass raise) -> (Process::Status | nil)
70
- | (Integer pid, TrueClass raise) -> nil
71
-
72
- # Spawns the specified command on a newly allocated pty. You can also use the
73
- # alias ::getpty.
74
- #
75
- # The command's controlling tty is set to the slave device of the pty and its
76
- # standard input/output/error is redirected to the slave device.
77
68
  #
78
- # `command` and `command_line` are the full commands to run, given a String. Any
79
- # additional `arguments` will be passed to the command.
80
- #
81
- # ### Return values
82
- #
83
- # In the non-block form this returns an array of size three, `[r, w, pid]`.
84
- #
85
- # In the block form these same values will be yielded to the block:
86
- #
87
- # `r`
88
- # : A readable IO that contains the command's standard output and standard
89
- # error
90
- # `w`
91
- # : A writable IO that is the command's standard input
92
- # `pid`
93
- # : The process identifier for the command.
94
- def self.getpty: (*String command) -> [ IO, IO, Integer ]
95
- | (*String command) { ([ IO ,IO , Integer ]) -> untyped } -> untyped
69
+ def self.check: (Integer pid, ?bool raise) -> Process::Status?
70
+
71
+ alias self.getpty self.spawn
96
72
 
97
73
  # Allocates a pty (pseudo-terminal).
98
74
  #
@@ -130,7 +106,7 @@ module PTY
130
106
  # ...
131
107
  # }
132
108
  def self.open: () -> [ IO, File ]
133
- | () { ([ IO , File ]) -> untyped } -> untyped
109
+ | [A] () { ([ IO , File ]) -> A } -> A
134
110
 
135
111
  # Spawns the specified command on a newly allocated pty. You can also use the
136
112
  # alias ::getpty.
@@ -155,5 +131,5 @@ module PTY
155
131
  # `pid`
156
132
  # : The process identifier for the command.
157
133
  def self.spawn: (*String command) -> [ IO, IO, Integer ]
158
- | (*String command) {([ IO , IO , Integer ]) -> untyped } -> untyped
134
+ | (*String command) {([ IO , IO , Integer ]) -> void } -> void
159
135
  end
@@ -232,7 +232,7 @@ class Set[A]
232
232
  # Set[1, 2, 3].intersect? Set[4, 5] #=> false
233
233
  # Set[1, 2, 3].intersect? Set[3, 4] #=> true
234
234
  #
235
- def intersect?: () -> bool
235
+ def intersect?: (self) -> bool
236
236
 
237
237
  # Deletes every element of the set for which block evaluates to false, and
238
238
  # returns self. Returns an enumerator if no block is given.
@@ -0,0 +1,167 @@
1
+ # URI is a module providing classes to handle Uniform Resource Identifiers
2
+ # ([RFC2396](http://tools.ietf.org/html/rfc2396)).
3
+ #
4
+ # ## Features
5
+ #
6
+ # * Uniform way of handling URIs.
7
+ # * Flexibility to introduce custom URI schemes.
8
+ # * Flexibility to have an alternate URI::Parser (or just different patterns
9
+ # and regexp's).
10
+ #
11
+ #
12
+ # ## Basic example
13
+ #
14
+ # require 'uri'
15
+ #
16
+ # uri = URI("http://foo.com/posts?id=30&limit=5#time=1305298413")
17
+ # #=> #<URI::HTTP http://foo.com/posts?id=30&limit=5#time=1305298413>
18
+ #
19
+ # uri.scheme #=> "http"
20
+ # uri.host #=> "foo.com"
21
+ # uri.path #=> "/posts"
22
+ # uri.query #=> "id=30&limit=5"
23
+ # uri.fragment #=> "time=1305298413"
24
+ #
25
+ # uri.to_s #=> "http://foo.com/posts?id=30&limit=5#time=1305298413"
26
+ #
27
+ # ## Adding custom URIs
28
+ #
29
+ # module URI
30
+ # class RSYNC < Generic
31
+ # DEFAULT_PORT = 873
32
+ # end
33
+ # @@schemes['RSYNC'] = RSYNC
34
+ # end
35
+ # #=> URI::RSYNC
36
+ #
37
+ # URI.scheme_list
38
+ # #=> {"FILE"=>URI::File, "FTP"=>URI::FTP, "HTTP"=>URI::HTTP,
39
+ # # "HTTPS"=>URI::HTTPS, "LDAP"=>URI::LDAP, "LDAPS"=>URI::LDAPS,
40
+ # # "MAILTO"=>URI::MailTo, "RSYNC"=>URI::RSYNC}
41
+ #
42
+ # uri = URI("rsync://rsync.foo.com")
43
+ # #=> #<URI::RSYNC rsync://rsync.foo.com>
44
+ #
45
+ # ## RFC References
46
+ #
47
+ # A good place to view an RFC spec is http://www.ietf.org/rfc.html.
48
+ #
49
+ # Here is a list of all related RFC's:
50
+ # * [RFC822](http://tools.ietf.org/html/rfc822)
51
+ # * [RFC1738](http://tools.ietf.org/html/rfc1738)
52
+ # * [RFC2255](http://tools.ietf.org/html/rfc2255)
53
+ # * [RFC2368](http://tools.ietf.org/html/rfc2368)
54
+ # * [RFC2373](http://tools.ietf.org/html/rfc2373)
55
+ # * [RFC2396](http://tools.ietf.org/html/rfc2396)
56
+ # * [RFC2732](http://tools.ietf.org/html/rfc2732)
57
+ # * [RFC3986](http://tools.ietf.org/html/rfc3986)
58
+ #
59
+ #
60
+ # ## Class tree
61
+ #
62
+ # * URI::Generic (in uri/generic.rb)
63
+ # * URI::File - (in uri/file.rb)
64
+ # * URI::FTP - (in uri/ftp.rb)
65
+ # * URI::HTTP - (in uri/http.rb)
66
+ # * URI::HTTPS - (in uri/https.rb)
67
+ #
68
+ # * URI::LDAP - (in uri/ldap.rb)
69
+ # * URI::LDAPS - (in uri/ldaps.rb)
70
+ #
71
+ # * URI::MailTo - (in uri/mailto.rb)
72
+ #
73
+ # * URI::Parser - (in uri/common.rb)
74
+ # * URI::REGEXP - (in uri/common.rb)
75
+ # * URI::REGEXP::PATTERN - (in uri/common.rb)
76
+ #
77
+ # * URI::Util - (in uri/common.rb)
78
+ # * URI::Escape - (in uri/common.rb)
79
+ # * URI::Error - (in uri/common.rb)
80
+ # * URI::InvalidURIError - (in uri/common.rb)
81
+ # * URI::InvalidComponentError - (in uri/common.rb)
82
+ # * URI::BadURIError - (in uri/common.rb)
83
+ #
84
+ #
85
+ #
86
+ # ## Copyright Info
87
+ #
88
+ # Author
89
+ # : Akira Yamada <akira@ruby-lang.org>
90
+ # Documentation
91
+ # : Akira Yamada <akira@ruby-lang.org> Dmitry V. Sabanin <sdmitry@lrn.ru>
92
+ # Vincent Batts <vbatts@hashbangbash.com>
93
+ # License
94
+ # : Copyright (c) 2001 akira yamada <akira@ruby-lang.org> You can redistribute
95
+ # it and/or modify it under the same term as Ruby.
96
+ # Revision
97
+ # : $Id$
98
+ #
99
+ #
100
+ module URI
101
+ #
102
+ # The "file" URI is defined by RFC8089.
103
+ #
104
+ class File < Generic
105
+ # A Default port of nil for URI::File.
106
+ DEFAULT_PORT: Integer?
107
+
108
+ #
109
+ # An Array of the available components for URI::File.
110
+ #
111
+ COMPONENT: Array[Symbol]
112
+
113
+ #
114
+ # == Description
115
+ #
116
+ # Creates a new URI::File object from components, with syntax checking.
117
+ #
118
+ # The components accepted are +host+ and +path+.
119
+ #
120
+ # The components should be provided either as an Array, or as a Hash
121
+ # with keys formed by preceding the component names with a colon.
122
+ #
123
+ # If an Array is used, the components must be passed in the
124
+ # order <code>[host, path]</code>.
125
+ #
126
+ # Examples:
127
+ #
128
+ # require 'uri'
129
+ #
130
+ # uri1 = URI::File.build(['host.example.com', '/path/file.zip'])
131
+ # uri1.to_s # => "file://host.example.com/path/file.zip"
132
+ #
133
+ # uri2 = URI::File.build({:host => 'host.example.com',
134
+ # :path => '/ruby/src'})
135
+ # uri2.to_s # => "file://host.example.com/ruby/src"
136
+ #
137
+ def self.build: (Array[String] args) -> URI::File
138
+ | ({ host: String, path: String }) -> URI::File
139
+
140
+ # Protected setter for the host component +v+.
141
+ #
142
+ # See also URI::Generic.host=.
143
+ #
144
+ def set_host: (String? v) -> String
145
+
146
+ # do nothing
147
+ def set_port: (Integer v) -> nil
148
+
149
+ # raise InvalidURIError
150
+ def check_userinfo: (String user) -> nil
151
+
152
+ # raise InvalidURIError
153
+ def check_user: (String user) -> nil
154
+
155
+ # raise InvalidURIError
156
+ def check_password: (String user) -> nil
157
+
158
+ # do nothing
159
+ def set_userinfo: (String v) -> nil
160
+
161
+ # do nothing
162
+ def set_user: (String v) -> nil
163
+
164
+ # do nothing
165
+ def set_password: (String v) -> nil
166
+ end
167
+ end
@@ -0,0 +1,875 @@
1
+ # URI is a module providing classes to handle Uniform Resource Identifiers
2
+ # ([RFC2396](http://tools.ietf.org/html/rfc2396)).
3
+ #
4
+ # ## Features
5
+ #
6
+ # * Uniform way of handling URIs.
7
+ # * Flexibility to introduce custom URI schemes.
8
+ # * Flexibility to have an alternate URI::Parser (or just different patterns
9
+ # and regexp's).
10
+ #
11
+ #
12
+ # ## Basic example
13
+ #
14
+ # require 'uri'
15
+ #
16
+ # uri = URI("http://foo.com/posts?id=30&limit=5#time=1305298413")
17
+ # #=> #<URI::HTTP http://foo.com/posts?id=30&limit=5#time=1305298413>
18
+ #
19
+ # uri.scheme #=> "http"
20
+ # uri.host #=> "foo.com"
21
+ # uri.path #=> "/posts"
22
+ # uri.query #=> "id=30&limit=5"
23
+ # uri.fragment #=> "time=1305298413"
24
+ #
25
+ # uri.to_s #=> "http://foo.com/posts?id=30&limit=5#time=1305298413"
26
+ #
27
+ # ## Adding custom URIs
28
+ #
29
+ # module URI
30
+ # class RSYNC < Generic
31
+ # DEFAULT_PORT = 873
32
+ # end
33
+ # @@schemes['RSYNC'] = RSYNC
34
+ # end
35
+ # #=> URI::RSYNC
36
+ #
37
+ # URI.scheme_list
38
+ # #=> {"FILE"=>URI::File, "FTP"=>URI::FTP, "HTTP"=>URI::HTTP,
39
+ # # "HTTPS"=>URI::HTTPS, "LDAP"=>URI::LDAP, "LDAPS"=>URI::LDAPS,
40
+ # # "MAILTO"=>URI::MailTo, "RSYNC"=>URI::RSYNC}
41
+ #
42
+ # uri = URI("rsync://rsync.foo.com")
43
+ # #=> #<URI::RSYNC rsync://rsync.foo.com>
44
+ #
45
+ # ## RFC References
46
+ #
47
+ # A good place to view an RFC spec is http://www.ietf.org/rfc.html.
48
+ #
49
+ # Here is a list of all related RFC's:
50
+ # * [RFC822](http://tools.ietf.org/html/rfc822)
51
+ # * [RFC1738](http://tools.ietf.org/html/rfc1738)
52
+ # * [RFC2255](http://tools.ietf.org/html/rfc2255)
53
+ # * [RFC2368](http://tools.ietf.org/html/rfc2368)
54
+ # * [RFC2373](http://tools.ietf.org/html/rfc2373)
55
+ # * [RFC2396](http://tools.ietf.org/html/rfc2396)
56
+ # * [RFC2732](http://tools.ietf.org/html/rfc2732)
57
+ # * [RFC3986](http://tools.ietf.org/html/rfc3986)
58
+ #
59
+ #
60
+ # ## Class tree
61
+ #
62
+ # * URI::Generic (in uri/generic.rb)
63
+ # * URI::File - (in uri/file.rb)
64
+ # * URI::FTP - (in uri/ftp.rb)
65
+ # * URI::HTTP - (in uri/http.rb)
66
+ # * URI::HTTPS - (in uri/https.rb)
67
+ #
68
+ # * URI::LDAP - (in uri/ldap.rb)
69
+ # * URI::LDAPS - (in uri/ldaps.rb)
70
+ #
71
+ # * URI::MailTo - (in uri/mailto.rb)
72
+ #
73
+ # * URI::Parser - (in uri/common.rb)
74
+ # * URI::REGEXP - (in uri/common.rb)
75
+ # * URI::REGEXP::PATTERN - (in uri/common.rb)
76
+ #
77
+ # * URI::Util - (in uri/common.rb)
78
+ # * URI::Escape - (in uri/common.rb)
79
+ # * URI::Error - (in uri/common.rb)
80
+ # * URI::InvalidURIError - (in uri/common.rb)
81
+ # * URI::InvalidComponentError - (in uri/common.rb)
82
+ # * URI::BadURIError - (in uri/common.rb)
83
+ #
84
+ #
85
+ #
86
+ # ## Copyright Info
87
+ #
88
+ # Author
89
+ # : Akira Yamada <akira@ruby-lang.org>
90
+ # Documentation
91
+ # : Akira Yamada <akira@ruby-lang.org> Dmitry V. Sabanin <sdmitry@lrn.ru>
92
+ # Vincent Batts <vbatts@hashbangbash.com>
93
+ # License
94
+ # : Copyright (c) 2001 akira yamada <akira@ruby-lang.org> You can redistribute
95
+ # it and/or modify it under the same term as Ruby.
96
+ # Revision
97
+ # : $Id$
98
+ #
99
+ #
100
+ module URI
101
+ #
102
+ # Base class for all URI classes.
103
+ # Implements generic URI syntax as per RFC 2396.
104
+ #
105
+ class Generic
106
+ include URI
107
+
108
+ #
109
+ # A Default port of nil for URI::Generic.
110
+ #
111
+ DEFAULT_PORT: nil | Integer
112
+
113
+ #
114
+ # Returns default port.
115
+ #
116
+ def self.default_port: () -> (nil | Integer)
117
+
118
+ #
119
+ # Returns default port.
120
+ #
121
+ def default_port: () -> (nil | Integer)
122
+
123
+ #
124
+ # An Array of the available components for URI::Generic.
125
+ #
126
+ COMPONENT: Array[Symbol]
127
+
128
+ #
129
+ # Components of the URI in the order.
130
+ #
131
+ def self.component: () -> Array[Symbol]
132
+
133
+ USE_REGISTRY: bool
134
+
135
+ def self.use_registry: () -> bool
136
+
137
+ #
138
+ # == Synopsis
139
+ #
140
+ # See ::new.
141
+ #
142
+ # == Description
143
+ #
144
+ # At first, tries to create a new URI::Generic instance using
145
+ # URI::Generic::build. But, if exception URI::InvalidComponentError is raised,
146
+ # then it does URI::Escape.escape all URI components and tries again.
147
+ #
148
+ def self.build2: (Array[nil | String | Integer]) -> URI::Generic
149
+ | ({ scheme: String, userinfo: String, host: String, port: Integer, registry: String?, path: String, opaque: String?, query: String, fragment: String }) -> URI::Generic
150
+
151
+ #
152
+ # == Synopsis
153
+ #
154
+ # See ::new.
155
+ #
156
+ # == Description
157
+ #
158
+ # Creates a new URI::Generic instance from components of URI::Generic
159
+ # with check. Components are: scheme, userinfo, host, port, registry, path,
160
+ # opaque, query, and fragment. You can provide arguments either by an Array or a Hash.
161
+ # See ::new for hash keys to use or for order of array items.
162
+ #
163
+ def self.build: (Array[nil | String | Integer]) -> URI::Generic
164
+ | ({ scheme: String, userinfo: String, host: String, port: Integer, registry: String?, path: String, opaque: String?, query: String, fragment: String }) -> URI::Generic
165
+
166
+ #
167
+ # == Args
168
+ #
169
+ # +scheme+::
170
+ # Protocol scheme, i.e. 'http','ftp','mailto' and so on.
171
+ # +userinfo+::
172
+ # User name and password, i.e. 'sdmitry:bla'.
173
+ # +host+::
174
+ # Server host name.
175
+ # +port+::
176
+ # Server port.
177
+ # +registry+::
178
+ # Registry of naming authorities.
179
+ # +path+::
180
+ # Path on server.
181
+ # +opaque+::
182
+ # Opaque part.
183
+ # +query+::
184
+ # Query data.
185
+ # +fragment+::
186
+ # Part of the URI after '#' character.
187
+ # +parser+::
188
+ # Parser for internal use [URI::DEFAULT_PARSER by default].
189
+ # +arg_check+::
190
+ # Check arguments [false by default].
191
+ #
192
+ # == Description
193
+ #
194
+ # Creates a new URI::Generic instance from ``generic'' components without check.
195
+ #
196
+ def initialize: (String scheme, String userinfo, String host, Integer port, String? registry, String path, String? opaque, String query, String fragment, ?untyped parser, ?bool arg_check) -> URI::Generic
197
+
198
+ #
199
+ # Returns the scheme component of the URI.
200
+ #
201
+ # URI("http://foo/bar/baz").scheme #=> "http"
202
+ #
203
+ attr_reader scheme: String
204
+
205
+ # Returns the host component of the URI.
206
+ #
207
+ # URI("http://foo/bar/baz").host #=> "foo"
208
+ #
209
+ # It returns nil if no host component exists.
210
+ #
211
+ # URI("mailto:foo@example.org").host #=> nil
212
+ #
213
+ # The component does not contain the port number.
214
+ #
215
+ # URI("http://foo:8080/bar/baz").host #=> "foo"
216
+ #
217
+ # Since IPv6 addresses are wrapped with brackets in URIs,
218
+ # this method returns IPv6 addresses wrapped with brackets.
219
+ # This form is not appropriate to pass to socket methods such as TCPSocket.open.
220
+ # If unwrapped host names are required, use the #hostname method.
221
+ #
222
+ # URI("http://[::1]/bar/baz").host #=> "[::1]"
223
+ # URI("http://[::1]/bar/baz").hostname #=> "::1"
224
+ #
225
+ attr_reader host: String
226
+
227
+ # Returns the port component of the URI.
228
+ #
229
+ # URI("http://foo/bar/baz").port #=> 80
230
+ # URI("http://foo:8080/bar/baz").port #=> 8080
231
+ #
232
+ attr_reader port: Integer
233
+
234
+ def registry: () -> nil
235
+
236
+ # Returns the path component of the URI.
237
+ #
238
+ # URI("http://foo/bar/baz").path #=> "/bar/baz"
239
+ #
240
+ attr_reader path: String
241
+
242
+ # Returns the query component of the URI.
243
+ #
244
+ # URI("http://foo/bar/baz?search=FooBar").query #=> "search=FooBar"
245
+ #
246
+ attr_reader query: String
247
+
248
+ # Returns the opaque part of the URI.
249
+ #
250
+ # URI("mailto:foo@example.org").opaque #=> "foo@example.org"
251
+ # URI("http://foo/bar/baz").opaque #=> nil
252
+ #
253
+ # The portion of the path that does not make use of the slash '/'.
254
+ # The path typically refers to an absolute path or an opaque part.
255
+ # (See RFC2396 Section 3 and 5.2.)
256
+ #
257
+ attr_reader opaque: String?
258
+
259
+ # Returns the fragment component of the URI.
260
+ #
261
+ # URI("http://foo/bar/baz?search=FooBar#ponies").fragment #=> "ponies"
262
+ #
263
+ attr_reader fragment: String
264
+
265
+ # Returns the parser to be used.
266
+ #
267
+ # Unless a URI::Parser is defined, DEFAULT_PARSER is used.
268
+ #
269
+ def parser: () -> untyped
270
+
271
+ # Replaces self by other URI object.
272
+ #
273
+ def replace!: (URI::Generic oth) -> URI::Generic
274
+
275
+ #
276
+ # Components of the URI in the order.
277
+ #
278
+ def component: () -> Array[Symbol]
279
+
280
+ #
281
+ # Checks the scheme +v+ component against the URI::Parser Regexp for :SCHEME.
282
+ #
283
+ def check_scheme: (String v) -> true
284
+
285
+ # Protected setter for the scheme component +v+.
286
+ #
287
+ # See also URI::Generic.scheme=.
288
+ #
289
+ def set_scheme: (String v) -> String
290
+
291
+ #
292
+ # == Args
293
+ #
294
+ # +v+::
295
+ # String
296
+ #
297
+ # == Description
298
+ #
299
+ # Public setter for the scheme component +v+
300
+ # (with validation).
301
+ #
302
+ # See also URI::Generic.check_scheme.
303
+ #
304
+ # == Usage
305
+ #
306
+ # require 'uri'
307
+ #
308
+ # uri = URI.parse("http://my.example.com")
309
+ # uri.scheme = "https"
310
+ # uri.to_s #=> "https://my.example.com"
311
+ #
312
+ def scheme=: (String v) -> String
313
+
314
+ #
315
+ # Checks the +user+ and +password+.
316
+ #
317
+ # If +password+ is not provided, then +user+ is
318
+ # split, using URI::Generic.split_userinfo, to
319
+ # pull +user+ and +password.
320
+ #
321
+ # See also URI::Generic.check_user, URI::Generic.check_password.
322
+ #
323
+ def check_userinfo: (String user, ?String? password) -> true
324
+
325
+ #
326
+ # Checks the user +v+ component for RFC2396 compliance
327
+ # and against the URI::Parser Regexp for :USERINFO.
328
+ #
329
+ # Can not have a registry or opaque component defined,
330
+ # with a user component defined.
331
+ #
332
+ def check_user: (String v) -> (String | true)
333
+
334
+ #
335
+ # Checks the password +v+ component for RFC2396 compliance
336
+ # and against the URI::Parser Regexp for :USERINFO.
337
+ #
338
+ # Can not have a registry or opaque component defined,
339
+ # with a user component defined.
340
+ #
341
+ def check_password: (String v, ?String user) -> (String | true)
342
+
343
+ #
344
+ # Sets userinfo, argument is string like 'name:pass'.
345
+ #
346
+ def userinfo=: (String? userinfo) -> Array[String | nil]?
347
+
348
+ #
349
+ # == Args
350
+ #
351
+ # +v+::
352
+ # String
353
+ #
354
+ # == Description
355
+ #
356
+ # Public setter for the +user+ component
357
+ # (with validation).
358
+ #
359
+ # See also URI::Generic.check_user.
360
+ #
361
+ # == Usage
362
+ #
363
+ # require 'uri'
364
+ #
365
+ # uri = URI.parse("http://john:S3nsit1ve@my.example.com")
366
+ # uri.user = "sam"
367
+ # uri.to_s #=> "http://sam:V3ry_S3nsit1ve@my.example.com"
368
+ #
369
+ def user=: (String user) -> String
370
+
371
+ #
372
+ # == Args
373
+ #
374
+ # +v+::
375
+ # String
376
+ #
377
+ # == Description
378
+ #
379
+ # Public setter for the +password+ component
380
+ # (with validation).
381
+ #
382
+ # See also URI::Generic.check_password.
383
+ #
384
+ # == Usage
385
+ #
386
+ # require 'uri'
387
+ #
388
+ # uri = URI.parse("http://john:S3nsit1ve@my.example.com")
389
+ # uri.password = "V3ry_S3nsit1ve"
390
+ # uri.to_s #=> "http://john:V3ry_S3nsit1ve@my.example.com"
391
+ #
392
+ def password=: (String password) -> String
393
+
394
+ # Protected setter for the +user+ component, and +password+ if available
395
+ # (with validation).
396
+ #
397
+ # See also URI::Generic.userinfo=.
398
+ #
399
+ def set_userinfo: (String user, ?String? password) -> Array[String | nil]
400
+
401
+ # Protected setter for the user component +v+.
402
+ #
403
+ # See also URI::Generic.user=.
404
+ #
405
+ def set_user: (String v) -> String
406
+
407
+ # Protected setter for the password component +v+.
408
+ #
409
+ # See also URI::Generic.password=.
410
+ #
411
+ def set_password: (String v) -> String
412
+
413
+ # Returns the userinfo +ui+ as <code>[user, password]</code>
414
+ # if properly formatted as 'user:password'.
415
+ def split_userinfo: (String ui) -> Array[String | nil]
416
+
417
+ # Escapes 'user:password' +v+ based on RFC 1738 section 3.1.
418
+ def escape_userpass: (String v) -> String
419
+
420
+ # Returns the userinfo, either as 'user' or 'user:password'.
421
+ def userinfo: () -> String?
422
+
423
+ # Returns the user component.
424
+ def user: () -> String
425
+
426
+ # Returns the password component.
427
+ def password: () -> String
428
+
429
+ #
430
+ # Checks the host +v+ component for RFC2396 compliance
431
+ # and against the URI::Parser Regexp for :HOST.
432
+ #
433
+ # Can not have a registry or opaque component defined,
434
+ # with a host component defined.
435
+ #
436
+ def check_host: (String v) -> (String | true)
437
+
438
+ # Protected setter for the host component +v+.
439
+ #
440
+ # See also URI::Generic.host=.
441
+ #
442
+ def set_host: (String v) -> String
443
+
444
+ #
445
+ # == Args
446
+ #
447
+ # +v+::
448
+ # String
449
+ #
450
+ # == Description
451
+ #
452
+ # Public setter for the host component +v+
453
+ # (with validation).
454
+ #
455
+ # See also URI::Generic.check_host.
456
+ #
457
+ # == Usage
458
+ #
459
+ # require 'uri'
460
+ #
461
+ # uri = URI.parse("http://my.example.com")
462
+ # uri.host = "foo.com"
463
+ # uri.to_s #=> "http://foo.com"
464
+ #
465
+ def host=: (String v) -> String
466
+
467
+ # Extract the host part of the URI and unwrap brackets for IPv6 addresses.
468
+ #
469
+ # This method is the same as URI::Generic#host except
470
+ # brackets for IPv6 (and future IP) addresses are removed.
471
+ #
472
+ # uri = URI("http://[::1]/bar")
473
+ # uri.hostname #=> "::1"
474
+ # uri.host #=> "[::1]"
475
+ #
476
+ def hostname: () -> String
477
+
478
+ # Sets the host part of the URI as the argument with brackets for IPv6 addresses.
479
+ #
480
+ # This method is the same as URI::Generic#host= except
481
+ # the argument can be a bare IPv6 address.
482
+ #
483
+ # uri = URI("http://foo/bar")
484
+ # uri.hostname = "::1"
485
+ # uri.to_s #=> "http://[::1]/bar"
486
+ #
487
+ # If the argument seems to be an IPv6 address,
488
+ # it is wrapped with brackets.
489
+ #
490
+ def hostname=: (String v) -> String
491
+
492
+ #
493
+ # Checks the port +v+ component for RFC2396 compliance
494
+ # and against the URI::Parser Regexp for :PORT.
495
+ #
496
+ # Can not have a registry or opaque component defined,
497
+ # with a port component defined.
498
+ #
499
+ def check_port: (Integer v) -> (Integer | true)
500
+
501
+ # Protected setter for the port component +v+.
502
+ #
503
+ # See also URI::Generic.port=.
504
+ #
505
+ def set_port: (Integer v) -> Integer
506
+
507
+ #
508
+ # == Args
509
+ #
510
+ # +v+::
511
+ # String
512
+ #
513
+ # == Description
514
+ #
515
+ # Public setter for the port component +v+
516
+ # (with validation).
517
+ #
518
+ # See also URI::Generic.check_port.
519
+ #
520
+ # == Usage
521
+ #
522
+ # require 'uri'
523
+ #
524
+ # uri = URI.parse("http://my.example.com")
525
+ # uri.port = 8080
526
+ # uri.to_s #=> "http://my.example.com:8080"
527
+ #
528
+ def port=: (Integer v) -> Integer
529
+
530
+ def check_registry: (String v) -> nil
531
+
532
+ def set_registry: (String v) -> nil
533
+
534
+ def registry=: (String v) -> nil
535
+
536
+ #
537
+ # Checks the path +v+ component for RFC2396 compliance
538
+ # and against the URI::Parser Regexp
539
+ # for :ABS_PATH and :REL_PATH.
540
+ #
541
+ # Can not have a opaque component defined,
542
+ # with a path component defined.
543
+ #
544
+ def check_path: (String v) -> true
545
+
546
+ # Protected setter for the path component +v+.
547
+ #
548
+ # See also URI::Generic.path=.
549
+ #
550
+ def set_path: (String v) -> String
551
+
552
+ #
553
+ # == Args
554
+ #
555
+ # +v+::
556
+ # String
557
+ #
558
+ # == Description
559
+ #
560
+ # Public setter for the path component +v+
561
+ # (with validation).
562
+ #
563
+ # See also URI::Generic.check_path.
564
+ #
565
+ # == Usage
566
+ #
567
+ # require 'uri'
568
+ #
569
+ # uri = URI.parse("http://my.example.com/pub/files")
570
+ # uri.path = "/faq/"
571
+ # uri.to_s #=> "http://my.example.com/faq/"
572
+ #
573
+ def path=: (String v) -> String
574
+
575
+ #
576
+ # == Args
577
+ #
578
+ # +v+::
579
+ # String
580
+ #
581
+ # == Description
582
+ #
583
+ # Public setter for the query component +v+.
584
+ #
585
+ # == Usage
586
+ #
587
+ # require 'uri'
588
+ #
589
+ # uri = URI.parse("http://my.example.com/?id=25")
590
+ # uri.query = "id=1"
591
+ # uri.to_s #=> "http://my.example.com/?id=1"
592
+ #
593
+ def query=: (String v) -> String
594
+
595
+ #
596
+ # Checks the opaque +v+ component for RFC2396 compliance and
597
+ # against the URI::Parser Regexp for :OPAQUE.
598
+ #
599
+ # Can not have a host, port, user, or path component defined,
600
+ # with an opaque component defined.
601
+ #
602
+ def check_opaque: (String v) -> (String | true)
603
+
604
+ # Protected setter for the opaque component +v+.
605
+ #
606
+ # See also URI::Generic.opaque=.
607
+ #
608
+ def set_opaque: (String v) -> String
609
+
610
+ #
611
+ # == Args
612
+ #
613
+ # +v+::
614
+ # String
615
+ #
616
+ # == Description
617
+ #
618
+ # Public setter for the opaque component +v+
619
+ # (with validation).
620
+ #
621
+ # See also URI::Generic.check_opaque.
622
+ #
623
+ def opaque=: (String v) -> String
624
+
625
+ #
626
+ # Checks the fragment +v+ component against the URI::Parser Regexp for :FRAGMENT.
627
+ #
628
+ #
629
+ # == Args
630
+ #
631
+ # +v+::
632
+ # String
633
+ #
634
+ # == Description
635
+ #
636
+ # Public setter for the fragment component +v+
637
+ # (with validation).
638
+ #
639
+ # == Usage
640
+ #
641
+ # require 'uri'
642
+ #
643
+ # uri = URI.parse("http://my.example.com/?id=25#time=1305212049")
644
+ # uri.fragment = "time=1305212086"
645
+ # uri.to_s #=> "http://my.example.com/?id=25#time=1305212086"
646
+ #
647
+ def fragment=: (String v) -> String
648
+
649
+ #
650
+ # Returns true if URI is hierarchical.
651
+ #
652
+ # == Description
653
+ #
654
+ # URI has components listed in order of decreasing significance from left to right,
655
+ # see RFC3986 https://tools.ietf.org/html/rfc3986 1.2.3.
656
+ #
657
+ # == Usage
658
+ #
659
+ # require 'uri'
660
+ #
661
+ # uri = URI.parse("http://my.example.com/")
662
+ # uri.hierarchical?
663
+ # #=> true
664
+ # uri = URI.parse("mailto:joe@example.com")
665
+ # uri.hierarchical?
666
+ # #=> false
667
+ #
668
+ def hierarchical?: () -> bool
669
+
670
+ #
671
+ # Returns true if URI has a scheme (e.g. http:// or https://) specified.
672
+ #
673
+ def absolute?: () -> bool
674
+
675
+ #
676
+ # Returns true if URI does not have a scheme (e.g. http:// or https://) specified.
677
+ #
678
+ def relative?: () -> bool
679
+
680
+ #
681
+ # Returns an Array of the path split on '/'.
682
+ #
683
+ def split_path: (String path) -> Array[String]
684
+
685
+ #
686
+ # Merges a base path +base+, with relative path +rel+,
687
+ # returns a modified base path.
688
+ #
689
+ def merge_path: (String base, String rel) -> String
690
+
691
+ #
692
+ # == Args
693
+ #
694
+ # +oth+::
695
+ # URI or String
696
+ #
697
+ # == Description
698
+ #
699
+ # Destructive form of #merge.
700
+ #
701
+ # == Usage
702
+ #
703
+ # require 'uri'
704
+ #
705
+ # uri = URI.parse("http://my.example.com")
706
+ # uri.merge!("/main.rbx?page=1")
707
+ # uri.to_s # => "http://my.example.com/main.rbx?page=1"
708
+ #
709
+ def merge!: (String oth) -> String
710
+
711
+ #
712
+ # == Args
713
+ #
714
+ # +oth+::
715
+ # URI or String
716
+ #
717
+ # == Description
718
+ #
719
+ # Merges two URIs.
720
+ #
721
+ # == Usage
722
+ #
723
+ # require 'uri'
724
+ #
725
+ # uri = URI.parse("http://my.example.com")
726
+ # uri.merge("/main.rbx?page=1")
727
+ # # => "http://my.example.com/main.rbx?page=1"
728
+ #
729
+ def merge: (String oth) -> URI::Generic
730
+
731
+ # :stopdoc:
732
+ def route_from_path: (String src, String dst) -> String
733
+
734
+ # :stopdoc:
735
+ def route_from0: (String oth) -> Array[URI::Generic]
736
+
737
+ #
738
+ # == Args
739
+ #
740
+ # +oth+::
741
+ # URI or String
742
+ #
743
+ # == Description
744
+ #
745
+ # Calculates relative path from oth to self.
746
+ #
747
+ # == Usage
748
+ #
749
+ # require 'uri'
750
+ #
751
+ # uri = URI.parse('http://my.example.com/main.rbx?page=1')
752
+ # uri.route_from('http://my.example.com')
753
+ # #=> #<URI::Generic /main.rbx?page=1>
754
+ #
755
+ def route_from: (String oth) -> URI::Generic
756
+
757
+ #
758
+ # == Args
759
+ #
760
+ # +oth+::
761
+ # URI or String
762
+ #
763
+ # == Description
764
+ #
765
+ # Calculates relative path to oth from self.
766
+ #
767
+ # == Usage
768
+ #
769
+ # require 'uri'
770
+ #
771
+ # uri = URI.parse('http://my.example.com')
772
+ # uri.route_to('http://my.example.com/main.rbx?page=1')
773
+ # #=> #<URI::Generic /main.rbx?page=1>
774
+ #
775
+ def route_to: (String oth) -> URI::Generic
776
+
777
+ #
778
+ # Returns normalized URI.
779
+ #
780
+ # require 'uri'
781
+ #
782
+ # URI("HTTP://my.EXAMPLE.com").normalize
783
+ # #=> #<URI::HTTP http://my.example.com/>
784
+ #
785
+ # Normalization here means:
786
+ #
787
+ # * scheme and host are converted to lowercase,
788
+ # * an empty path component is set to "/".
789
+ #
790
+ def normalize: () -> untyped
791
+
792
+ #
793
+ # Destructive version of #normalize.
794
+ #
795
+ def normalize!: () -> untyped
796
+
797
+ #
798
+ # Constructs String from URI.
799
+ #
800
+ def to_s: () -> String
801
+
802
+ #
803
+ # Compares two URIs.
804
+ #
805
+ def ==: (URI::Generic oth) -> bool
806
+
807
+ def hash: () -> Integer
808
+
809
+ def eql?: (URI::Generic oth) -> bool
810
+
811
+ # Returns an Array of the components defined from the COMPONENT Array.
812
+ def component_ary: () -> Array[nil | String | Integer]
813
+
814
+ # == Args
815
+ #
816
+ # +components+::
817
+ # Multiple Symbol arguments defined in URI::HTTP.
818
+ #
819
+ # == Description
820
+ #
821
+ # Selects specified components from URI.
822
+ #
823
+ # == Usage
824
+ #
825
+ # require 'uri'
826
+ #
827
+ # uri = URI.parse('http://myuser:mypass@my.example.com/test.rbx')
828
+ # uri.select(:userinfo, :host, :path)
829
+ # # => ["myuser:mypass", "my.example.com", "/test.rbx"]
830
+ #
831
+ def select: (*Symbol components) -> Array[nil | String | Integer]
832
+
833
+ def inspect: () -> String
834
+
835
+ #
836
+ # == Args
837
+ #
838
+ # +v+::
839
+ # URI or String
840
+ #
841
+ # == Description
842
+ #
843
+ # Attempts to parse other URI +oth+,
844
+ # returns [parsed_oth, self].
845
+ #
846
+ # == Usage
847
+ #
848
+ # require 'uri'
849
+ #
850
+ # uri = URI.parse("http://my.example.com")
851
+ # uri.coerce("http://foo.com")
852
+ # #=> [#<URI::HTTP http://foo.com>, #<URI::HTTP http://my.example.com>]
853
+ #
854
+ def coerce: (URI::Generic | String oth) -> Array[URI::Generic]
855
+
856
+ # Returns a proxy URI.
857
+ # The proxy URI is obtained from environment variables such as http_proxy,
858
+ # ftp_proxy, no_proxy, etc.
859
+ # If there is no proper proxy, nil is returned.
860
+ #
861
+ # If the optional parameter +env+ is specified, it is used instead of ENV.
862
+ #
863
+ # Note that capitalized variables (HTTP_PROXY, FTP_PROXY, NO_PROXY, etc.)
864
+ # are examined, too.
865
+ #
866
+ # But http_proxy and HTTP_PROXY is treated specially under CGI environment.
867
+ # It's because HTTP_PROXY may be set by Proxy: header.
868
+ # So HTTP_PROXY is not used.
869
+ # http_proxy is not used too if the variable is case insensitive.
870
+ # CGI_HTTP_PROXY can be used instead.
871
+ def find_proxy: (?String env) -> (nil | URI::Generic)
872
+
873
+ def self.use_proxy?: (String hostname, String addr, Integer port, String no_proxy) -> bool
874
+ end
875
+ end