rbs 0.18.1 → 1.0.0.pre2

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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +31 -0
  3. data/Rakefile +12 -0
  4. data/Steepfile +2 -1
  5. data/bin/annotate-with-rdoc +0 -4
  6. data/core/builtin.rbs +4 -0
  7. data/core/file.rbs +3 -4
  8. data/core/hash.rbs +1 -3
  9. data/core/io.rbs +165 -7
  10. data/core/kernel.rbs +1 -1
  11. data/core/module.rbs +41 -0
  12. data/core/time.rbs +0 -12
  13. data/docs/syntax.md +0 -17
  14. data/goodcheck.yml +22 -2
  15. data/lib/rbs.rb +2 -0
  16. data/lib/rbs/ast/declarations.rb +7 -49
  17. data/lib/rbs/ast/members.rb +10 -4
  18. data/lib/rbs/cli.rb +10 -10
  19. data/lib/rbs/definition.rb +70 -3
  20. data/lib/rbs/definition_builder.rb +573 -984
  21. data/lib/rbs/definition_builder/ancestor_builder.rb +525 -0
  22. data/lib/rbs/definition_builder/method_builder.rb +217 -0
  23. data/lib/rbs/environment.rb +6 -8
  24. data/lib/rbs/environment_loader.rb +8 -4
  25. data/lib/rbs/errors.rb +88 -121
  26. data/lib/rbs/method_type.rb +1 -31
  27. data/lib/rbs/parser.rb +1082 -1014
  28. data/lib/rbs/parser.y +108 -76
  29. data/lib/rbs/prototype/rb.rb +18 -3
  30. data/lib/rbs/prototype/rbi.rb +6 -6
  31. data/lib/rbs/prototype/runtime.rb +71 -35
  32. data/lib/rbs/substitution.rb +4 -0
  33. data/lib/rbs/test.rb +3 -1
  34. data/lib/rbs/test/hook.rb +26 -8
  35. data/lib/rbs/types.rb +68 -7
  36. data/lib/rbs/validator.rb +4 -2
  37. data/lib/rbs/variance_calculator.rb +5 -1
  38. data/lib/rbs/version.rb +1 -1
  39. data/lib/rbs/writer.rb +13 -4
  40. data/schema/members.json +5 -1
  41. data/sig/ancestor_builder.rbs +98 -0
  42. data/sig/declarations.rbs +4 -16
  43. data/sig/definition.rbs +6 -1
  44. data/sig/definition_builder.rbs +15 -67
  45. data/sig/errors.rbs +159 -0
  46. data/sig/members.rbs +4 -1
  47. data/sig/method_builder.rbs +71 -0
  48. data/sig/method_types.rbs +3 -16
  49. data/sig/substitution.rbs +3 -0
  50. data/sig/type_name_resolver.rbs +4 -2
  51. data/sig/types.rbs +17 -15
  52. data/sig/validator.rbs +12 -0
  53. data/stdlib/csv/0/csv.rbs +3 -0
  54. data/stdlib/dbm/0/dbm.rbs +0 -2
  55. data/stdlib/logger/0/log_device.rbs +1 -2
  56. data/stdlib/monitor/0/monitor.rbs +119 -0
  57. data/stdlib/pathname/0/pathname.rbs +1 -1
  58. data/stdlib/prime/0/prime.rbs +6 -0
  59. data/stdlib/securerandom/0/securerandom.rbs +2 -0
  60. data/stdlib/time/0/time.rbs +327 -0
  61. data/stdlib/tsort/0/tsort.rbs +8 -0
  62. data/stdlib/uri/0/common.rbs +401 -0
  63. data/stdlib/uri/0/rfc2396_parser.rbs +9 -0
  64. data/stdlib/uri/0/rfc3986_parser.rbs +2 -0
  65. data/steep/Gemfile.lock +13 -14
  66. metadata +16 -5
@@ -115,7 +115,6 @@ module RBS
115
115
 
116
116
  class Variable
117
117
  attr_reader name: Symbol
118
- attr_reader location: Location?
119
118
 
120
119
  @@count: Integer
121
120
 
@@ -140,7 +139,6 @@ module RBS
140
139
 
141
140
  class ClassSingleton
142
141
  attr_reader name: TypeName
143
- attr_reader location: Location?
144
142
 
145
143
  include _TypeBase
146
144
 
@@ -178,8 +176,6 @@ module RBS
178
176
  class Interface
179
177
  include Application
180
178
 
181
- attr_reader location: Location?
182
-
183
179
  def initialize: (name: TypeName, args: Array[t], location: Location?) -> void
184
180
 
185
181
  include _TypeBase
@@ -194,15 +190,12 @@ module RBS
194
190
  class ClassInstance
195
191
  include Application
196
192
 
197
- attr_reader location: Location?
198
-
199
193
  def initialize: (name: TypeName, args: Array[t], location: Location?) -> void
200
194
 
201
195
  include _TypeBase
202
196
  end
203
197
 
204
198
  class Alias
205
- attr_reader location: Location?
206
199
  attr_reader name: TypeName
207
200
 
208
201
  def initialize: (name: TypeName, location: Location?) -> void
@@ -215,7 +208,6 @@ module RBS
215
208
 
216
209
  class Tuple
217
210
  attr_reader types: Array[t]
218
- attr_reader location: Location?
219
211
 
220
212
  def initialize: (types: Array[t], location: Location?) -> void
221
213
 
@@ -224,7 +216,6 @@ module RBS
224
216
 
225
217
  class Record
226
218
  attr_reader fields: Hash[Symbol, t]
227
- attr_reader location: Location?
228
219
 
229
220
  def initialize: (fields: Hash[Symbol, t], location: Location?) -> void
230
221
 
@@ -233,7 +224,6 @@ module RBS
233
224
 
234
225
  class Optional
235
226
  attr_reader type: t
236
- attr_reader location: Location?
237
227
 
238
228
  def initialize: (type: t, location: Location?) -> void
239
229
 
@@ -242,7 +232,6 @@ module RBS
242
232
 
243
233
  class Union
244
234
  attr_reader types: Array[t]
245
- attr_reader location: Location?
246
235
 
247
236
  def initialize: (types: Array[t], location: Location?) -> void
248
237
 
@@ -254,7 +243,6 @@ module RBS
254
243
 
255
244
  class Intersection
256
245
  attr_reader types: Array[t]
257
- attr_reader location: Location?
258
246
 
259
247
  def initialize: (types: Array[t], location: Location?) -> void
260
248
 
@@ -334,11 +322,26 @@ module RBS
334
322
  def has_keyword?: () -> bool
335
323
  end
336
324
 
325
+ class Block
326
+ attr_reader type: Types::Function
327
+ attr_reader required: bool
328
+
329
+ def initialize: (type: Types::Function, required: boolish) -> void
330
+
331
+ def ==: (untyped other) -> bool
332
+
333
+ def to_json: (*untyped) -> String
334
+
335
+ def sub: (Substitution) -> Block
336
+
337
+ def map_type: () { (Types::t) -> Types::t } -> Block
338
+ end
339
+
337
340
  class Proc
338
341
  attr_reader type: Function
339
- attr_reader location: Location?
342
+ attr_reader block: Block?
340
343
 
341
- def initialize: (location: Location?, type: Function) -> void
344
+ def initialize: (location: Location?, type: Function, block: Block?) -> void
342
345
 
343
346
  include _TypeBase
344
347
  end
@@ -347,7 +350,6 @@ module RBS
347
350
  type literal = String | Integer | Symbol | TrueClass | FalseClass
348
351
 
349
352
  attr_reader literal: literal
350
- attr_reader location: Location?
351
353
 
352
354
  def initialize: (literal: literal, location: Location?) -> void
353
355
 
@@ -0,0 +1,12 @@
1
+ module RBS
2
+ class Validator
3
+ attr_reader env: Environment
4
+ attr_reader resolver: TypeNameResolver
5
+
6
+ def initialize: (env: Environment, resolver: TypeNameResolver) -> void
7
+
8
+ def absolute_type: (Types::t, context: TypeNameResolver::context) { (Types::t) -> TypeName } -> Types::t
9
+
10
+ def validate_type: (Types::t, context: TypeNameResolver::context) -> void
11
+ end
12
+ end
@@ -160,6 +160,7 @@
160
160
  #
161
161
  class CSV < Object
162
162
  include Enumerable[untyped]
163
+ extend Forwardable
163
164
 
164
165
  # This method is intended as the primary interface for reading CSV files. You
165
166
  # pass a `path` and any `options` you wish to set for the read. Each row of file
@@ -408,6 +409,7 @@ CSV::VERSION: String
408
409
  #
409
410
  class CSV::Row < Object
410
411
  include Enumerable[untyped]
412
+ extend Forwardable
411
413
 
412
414
  # If a two-element Array is provided, it is assumed to be a header and field and
413
415
  # the pair is appended. A Hash works the same way with the key being the header
@@ -579,6 +581,7 @@ end
579
581
  #
580
582
  class CSV::Table[out Elem] < Object
581
583
  include Enumerable[untyped]
584
+ extend Forwardable
582
585
 
583
586
  # Constructs a new CSV::Table from `array_of_rows`, which are expected to be
584
587
  # CSV::Row objects. All rows are assumed to have the same headers.
@@ -138,8 +138,6 @@ class DBM
138
138
  #
139
139
  def include?: (String) -> bool
140
140
 
141
- def index: (untyped) -> (String | NilClass)
142
-
143
141
  # Returns a Hash (not a DBM database) created by using each value in the
144
142
  # database as a key, with the corresponding key as its value.
145
143
  #
@@ -1,7 +1,6 @@
1
1
  class Logger
2
2
  class LogDevice
3
- # TODO: Write type signature for MonitorMixin
4
- # include MonitorMixin
3
+ include MonitorMixin
5
4
 
6
5
  include Period
7
6
 
@@ -0,0 +1,119 @@
1
+ # Use the Monitor class when you want to have a lock object for blocks with
2
+ # mutual exclusion.
3
+ #
4
+ # require 'monitor'
5
+ #
6
+ # lock = Monitor.new
7
+ # lock.synchronize do
8
+ # # exclusive access
9
+ # end
10
+ class Monitor
11
+ public
12
+
13
+ def enter: () -> nil
14
+
15
+ def exit: () -> nil
16
+
17
+ def mon_check_owner: () -> nil
18
+
19
+ alias mon_enter enter
20
+
21
+ alias mon_exit exit
22
+
23
+ def mon_locked?: () -> bool
24
+
25
+ def mon_owned?: () -> bool
26
+
27
+ alias mon_synchronize synchronize
28
+
29
+ alias mon_try_enter try_enter
30
+
31
+ def new_cond: () -> ::MonitorMixin::ConditionVariable
32
+
33
+ def synchronize: [T] () { () -> T } -> T
34
+
35
+ def try_enter: () -> bool
36
+
37
+ # for compatibility
38
+ alias try_mon_enter try_enter
39
+
40
+ def wait_for_cond: (::MonitorMixin::ConditionVariable, Numeric? timeout) -> untyped
41
+ end
42
+
43
+ module MonitorMixin
44
+ def self.extend_object: (untyped obj) -> untyped
45
+
46
+ public
47
+
48
+ # Enters exclusive section.
49
+ def mon_enter: () -> nil
50
+
51
+ # Leaves exclusive section.
52
+ def mon_exit: () -> nil
53
+
54
+ # Returns true if this monitor is locked by any thread
55
+ def mon_locked?: () -> bool
56
+
57
+ # Returns true if this monitor is locked by current thread.
58
+ def mon_owned?: () -> bool
59
+
60
+ # Enters exclusive section and executes the block. Leaves the exclusive section
61
+ # automatically when the block exits. See example under `MonitorMixin`.
62
+ def mon_synchronize: [T] () { () -> T } -> T
63
+
64
+ # Attempts to enter exclusive section. Returns `false` if lock fails.
65
+ def mon_try_enter: () -> bool
66
+
67
+ # Creates a new MonitorMixin::ConditionVariable associated with the Monitor
68
+ # object.
69
+ def new_cond: () -> ::MonitorMixin::ConditionVariable
70
+
71
+ alias synchronize mon_synchronize
72
+
73
+ # For backward compatibility
74
+ alias try_mon_enter mon_try_enter
75
+
76
+ private
77
+
78
+ # Use `extend MonitorMixin` or `include MonitorMixin` instead of this
79
+ # constructor. Have look at the examples above to understand how to use this
80
+ # module.
81
+ def initialize: (*untyped) { (*untyped) -> untyped } -> void
82
+
83
+ def mon_check_owner: () -> nil
84
+
85
+ # Initializes the MonitorMixin after being included in a class or when an object
86
+ # has been extended with the MonitorMixin
87
+ def mon_initialize: () -> untyped
88
+ end
89
+
90
+ # FIXME: This isn't documented in Nutshell.
91
+ #
92
+ # Since MonitorMixin.new_cond returns a ConditionVariable, and the example above
93
+ # calls while_wait and signal, this class should be documented.
94
+ class MonitorMixin::ConditionVariable
95
+ public
96
+
97
+ # Wakes up all threads waiting for this lock.
98
+ def broadcast: () -> Thread::ConditionVariable
99
+
100
+ # Wakes up the first thread in line waiting for this lock.
101
+ def signal: () -> Thread::ConditionVariable
102
+
103
+ # Releases the lock held in the associated monitor and waits; reacquires the
104
+ # lock on wakeup.
105
+ #
106
+ # If `timeout` is given, this method returns after `timeout` seconds passed,
107
+ # even if no other thread doesn't signal.
108
+ def wait: (?Numeric? timeout) -> untyped
109
+
110
+ # Calls wait repeatedly until the given block yields a truthy value.
111
+ def wait_until: () { () -> boolish } -> untyped
112
+
113
+ # Calls wait repeatedly while the given block yields a truthy value.
114
+ def wait_while: () { () -> boolish } -> untyped
115
+
116
+ private
117
+
118
+ def initialize: (Monitor monitor) -> void
119
+ end
@@ -373,7 +373,7 @@ class Pathname
373
373
  # Note that the results never contain the entries `.` and `..` in the directory
374
374
  # because they are not children.
375
375
  #
376
- def children: (?boolish with_directory) -> untyped
376
+ def children: (?boolish with_directory) -> Array[Pathname]
377
377
 
378
378
  # Changes file permissions.
379
379
  #
@@ -42,6 +42,12 @@
42
42
  #
43
43
  #
44
44
  class Prime
45
+ include Singleton
46
+
47
+ include Enumerable[Integer]
48
+
49
+ extend Enumerable[Integer]
50
+
45
51
  # Iterates the given block over all prime numbers.
46
52
  #
47
53
  # ## Parameters
@@ -1,4 +1,6 @@
1
1
  module SecureRandom
2
+ extend Random::Formatter
3
+
2
4
  def self.alphanumeric: (?Integer?) -> String
3
5
  def self.base64: (?Integer?) -> String
4
6
  def self.hex: (?Integer?) -> String
@@ -0,0 +1,327 @@
1
+ class Time
2
+ interface _TimeLike
3
+ def year: () -> Integer
4
+ def mon: () -> Integer
5
+ def day: () -> Integer
6
+ end
7
+
8
+ #
9
+ # Return the number of seconds the specified time zone differs
10
+ # from UTC.
11
+ #
12
+ # Numeric time zones that include minutes, such as
13
+ # <code>-10:00</code> or <code>+1330</code> will work, as will
14
+ # simpler hour-only time zones like <code>-10</code> or
15
+ # <code>+13</code>.
16
+ #
17
+ # Textual time zones listed in ZoneOffset are also supported.
18
+ #
19
+ # If the time zone does not match any of the above, +zone_offset+
20
+ # will check if the local time zone (both with and without
21
+ # potential Daylight Saving \Time changes being in effect) matches
22
+ # +zone+. Specifying a value for +year+ will change the year used
23
+ # to find the local time zone.
24
+ #
25
+ # If +zone_offset+ is unable to determine the offset, nil will be
26
+ # returned.
27
+ #
28
+ # require 'time'
29
+ #
30
+ # Time.zone_offset("EST") #=> -18000
31
+ #
32
+ # You must require 'time' to use this method.
33
+ #
34
+ def self.zone_offset: (String zone, ?Integer year) -> Integer
35
+
36
+ #
37
+ # Takes a string representation of a Time and attempts to parse it
38
+ # using a heuristic.
39
+ #
40
+ # require 'time'
41
+ #
42
+ # Time.parse("2010-10-31") #=> 2010-10-31 00:00:00 -0500
43
+ #
44
+ # Any missing pieces of the date are inferred based on the current date.
45
+ #
46
+ # require 'time'
47
+ #
48
+ # # assuming the current date is "2011-10-31"
49
+ # Time.parse("12:00") #=> 2011-10-31 12:00:00 -0500
50
+ #
51
+ # We can change the date used to infer our missing elements by passing a second
52
+ # object that responds to #mon, #day and #year, such as Date, Time or DateTime.
53
+ # We can also use our own object.
54
+ #
55
+ # require 'time'
56
+ #
57
+ # class MyDate
58
+ # attr_reader :mon, :day, :year
59
+ #
60
+ # def initialize(mon, day, year)
61
+ # @mon, @day, @year = mon, day, year
62
+ # end
63
+ # end
64
+ #
65
+ # d = Date.parse("2010-10-28")
66
+ # t = Time.parse("2010-10-29")
67
+ # dt = DateTime.parse("2010-10-30")
68
+ # md = MyDate.new(10,31,2010)
69
+ #
70
+ # Time.parse("12:00", d) #=> 2010-10-28 12:00:00 -0500
71
+ # Time.parse("12:00", t) #=> 2010-10-29 12:00:00 -0500
72
+ # Time.parse("12:00", dt) #=> 2010-10-30 12:00:00 -0500
73
+ # Time.parse("12:00", md) #=> 2010-10-31 12:00:00 -0500
74
+ #
75
+ # If a block is given, the year described in +date+ is converted
76
+ # by the block. This is specifically designed for handling two
77
+ # digit years. For example, if you wanted to treat all two digit
78
+ # years prior to 70 as the year 2000+ you could write this:
79
+ #
80
+ # require 'time'
81
+ #
82
+ # Time.parse("01-10-31") {|year| year + (year < 70 ? 2000 : 1900)}
83
+ # #=> 2001-10-31 00:00:00 -0500
84
+ # Time.parse("70-10-31") {|year| year + (year < 70 ? 2000 : 1900)}
85
+ # #=> 1970-10-31 00:00:00 -0500
86
+ #
87
+ # If the upper components of the given time are broken or missing, they are
88
+ # supplied with those of +now+. For the lower components, the minimum
89
+ # values (1 or 0) are assumed if broken or missing. For example:
90
+ #
91
+ # require 'time'
92
+ #
93
+ # # Suppose it is "Thu Nov 29 14:33:20 2001" now and
94
+ # # your time zone is EST which is GMT-5.
95
+ # now = Time.parse("Thu Nov 29 14:33:20 2001")
96
+ # Time.parse("16:30", now) #=> 2001-11-29 16:30:00 -0500
97
+ # Time.parse("7/23", now) #=> 2001-07-23 00:00:00 -0500
98
+ # Time.parse("Aug 31", now) #=> 2001-08-31 00:00:00 -0500
99
+ # Time.parse("Aug 2000", now) #=> 2000-08-01 00:00:00 -0500
100
+ #
101
+ # Since there are numerous conflicts among locally defined time zone
102
+ # abbreviations all over the world, this method is not intended to
103
+ # understand all of them. For example, the abbreviation "CST" is
104
+ # used variously as:
105
+ #
106
+ # -06:00 in America/Chicago,
107
+ # -05:00 in America/Havana,
108
+ # +08:00 in Asia/Harbin,
109
+ # +09:30 in Australia/Darwin,
110
+ # +10:30 in Australia/Adelaide,
111
+ # etc.
112
+ #
113
+ # Based on this fact, this method only understands the time zone
114
+ # abbreviations described in RFC 822 and the system time zone, in the
115
+ # order named. (i.e. a definition in RFC 822 overrides the system
116
+ # time zone definition.) The system time zone is taken from
117
+ # <tt>Time.local(year, 1, 1).zone</tt> and
118
+ # <tt>Time.local(year, 7, 1).zone</tt>.
119
+ # If the extracted time zone abbreviation does not match any of them,
120
+ # it is ignored and the given time is regarded as a local time.
121
+ #
122
+ # ArgumentError is raised if Date._parse cannot extract information from
123
+ # +date+ or if the Time class cannot represent specified date.
124
+ #
125
+ # This method can be used as a fail-safe for other parsing methods as:
126
+ #
127
+ # Time.rfc2822(date) rescue Time.parse(date)
128
+ # Time.httpdate(date) rescue Time.parse(date)
129
+ # Time.xmlschema(date) rescue Time.parse(date)
130
+ #
131
+ # A failure of Time.parse should be checked, though.
132
+ #
133
+ # You must require 'time' to use this method.
134
+ #
135
+ def self.parse: (String date, ?_TimeLike now) ?{ (Integer) -> Integer } -> Time
136
+
137
+ #
138
+ # Works similar to +parse+ except that instead of using a
139
+ # heuristic to detect the format of the input string, you provide
140
+ # a second argument that describes the format of the string.
141
+ #
142
+ # If a block is given, the year described in +date+ is converted by the
143
+ # block. For example:
144
+ #
145
+ # Time.strptime(...) {|y| y < 100 ? (y >= 69 ? y + 1900 : y + 2000) : y}
146
+ #
147
+ # Below is a list of the formatting options:
148
+ #
149
+ # %a :: The abbreviated weekday name ("Sun")
150
+ # %A :: The full weekday name ("Sunday")
151
+ # %b :: The abbreviated month name ("Jan")
152
+ # %B :: The full month name ("January")
153
+ # %c :: The preferred local date and time representation
154
+ # %C :: Century (20 in 2009)
155
+ # %d :: Day of the month (01..31)
156
+ # %D :: Date (%m/%d/%y)
157
+ # %e :: Day of the month, blank-padded ( 1..31)
158
+ # %F :: Equivalent to %Y-%m-%d (the ISO 8601 date format)
159
+ # %g :: The last two digits of the commercial year
160
+ # %G :: The week-based year according to ISO-8601 (week 1 starts on Monday
161
+ # and includes January 4)
162
+ # %h :: Equivalent to %b
163
+ # %H :: Hour of the day, 24-hour clock (00..23)
164
+ # %I :: Hour of the day, 12-hour clock (01..12)
165
+ # %j :: Day of the year (001..366)
166
+ # %k :: hour, 24-hour clock, blank-padded ( 0..23)
167
+ # %l :: hour, 12-hour clock, blank-padded ( 0..12)
168
+ # %L :: Millisecond of the second (000..999)
169
+ # %m :: Month of the year (01..12)
170
+ # %M :: Minute of the hour (00..59)
171
+ # %n :: Newline (\n)
172
+ # %N :: Fractional seconds digits
173
+ # %p :: Meridian indicator ("AM" or "PM")
174
+ # %P :: Meridian indicator ("am" or "pm")
175
+ # %r :: time, 12-hour (same as %I:%M:%S %p)
176
+ # %R :: time, 24-hour (%H:%M)
177
+ # %s :: Number of seconds since 1970-01-01 00:00:00 UTC.
178
+ # %S :: Second of the minute (00..60)
179
+ # %t :: Tab character (\t)
180
+ # %T :: time, 24-hour (%H:%M:%S)
181
+ # %u :: Day of the week as a decimal, Monday being 1. (1..7)
182
+ # %U :: Week number of the current year, starting with the first Sunday as
183
+ # the first day of the first week (00..53)
184
+ # %v :: VMS date (%e-%b-%Y)
185
+ # %V :: Week number of year according to ISO 8601 (01..53)
186
+ # %W :: Week number of the current year, starting with the first Monday
187
+ # as the first day of the first week (00..53)
188
+ # %w :: Day of the week (Sunday is 0, 0..6)
189
+ # %x :: Preferred representation for the date alone, no time
190
+ # %X :: Preferred representation for the time alone, no date
191
+ # %y :: Year without a century (00..99)
192
+ # %Y :: Year which may include century, if provided
193
+ # %z :: Time zone as hour offset from UTC (e.g. +0900)
194
+ # %Z :: Time zone name
195
+ # %% :: Literal "%" character
196
+ # %+ :: date(1) (%a %b %e %H:%M:%S %Z %Y)
197
+ #
198
+ # require 'time'
199
+ #
200
+ # Time.strptime("2000-10-31", "%Y-%m-%d") #=> 2000-10-31 00:00:00 -0500
201
+ #
202
+ # You must require 'time' to use this method.
203
+ #
204
+ def self.strptime: (String date, String format, ?_TimeLike now) ?{ (Integer) -> Integer } -> Time
205
+
206
+ #
207
+ # Parses +date+ as date-time defined by RFC 2822 and converts it to a Time
208
+ # object. The format is identical to the date format defined by RFC 822 and
209
+ # updated by RFC 1123.
210
+ #
211
+ # ArgumentError is raised if +date+ is not compliant with RFC 2822
212
+ # or if the Time class cannot represent specified date.
213
+ #
214
+ # See #rfc2822 for more information on this format.
215
+ #
216
+ # require 'time'
217
+ #
218
+ # Time.rfc2822("Wed, 05 Oct 2011 22:26:12 -0400")
219
+ # #=> 2010-10-05 22:26:12 -0400
220
+ #
221
+ # You must require 'time' to use this method.
222
+ #
223
+ def self.rfc2822: (String date) -> Time
224
+
225
+ alias self.rfc822 self.rfc2822
226
+
227
+ #
228
+ # Parses +date+ as an HTTP-date defined by RFC 2616 and converts it to a
229
+ # Time object.
230
+ #
231
+ # ArgumentError is raised if +date+ is not compliant with RFC 2616 or if
232
+ # the Time class cannot represent specified date.
233
+ #
234
+ # See #httpdate for more information on this format.
235
+ #
236
+ # require 'time'
237
+ #
238
+ # Time.httpdate("Thu, 06 Oct 2011 02:26:12 GMT")
239
+ # #=> 2011-10-06 02:26:12 UTC
240
+ #
241
+ # You must require 'time' to use this method.
242
+ #
243
+ def self.httpdate: (String date) -> Time
244
+
245
+ #
246
+ # Parses +date+ as a dateTime defined by the XML Schema and converts it to
247
+ # a Time object. The format is a restricted version of the format defined
248
+ # by ISO 8601.
249
+ #
250
+ # ArgumentError is raised if +date+ is not compliant with the format or if
251
+ # the Time class cannot represent specified date.
252
+ #
253
+ # See #xmlschema for more information on this format.
254
+ #
255
+ # require 'time'
256
+ #
257
+ # Time.xmlschema("2011-10-05T22:26:12-04:00")
258
+ # #=> 2011-10-05 22:26:12-04:00
259
+ #
260
+ # You must require 'time' to use this method.
261
+ #
262
+ def self.xmlschema: (String date) -> Time
263
+
264
+ alias self.iso8601 self.xmlschema
265
+
266
+ #
267
+ # Returns a string which represents the time as date-time defined by RFC 2822:
268
+ #
269
+ # day-of-week, DD month-name CCYY hh:mm:ss zone
270
+ #
271
+ # where zone is [+-]hhmm.
272
+ #
273
+ # If +self+ is a UTC time, -0000 is used as zone.
274
+ #
275
+ # require 'time'
276
+ #
277
+ # t = Time.now
278
+ # t.rfc2822 # => "Wed, 05 Oct 2011 22:26:12 -0400"
279
+ #
280
+ # You must require 'time' to use this method.
281
+ #
282
+ def rfc2822: () -> String
283
+
284
+ alias rfc822 rfc2822
285
+
286
+ #
287
+ # Returns a string which represents the time as RFC 1123 date of HTTP-date
288
+ # defined by RFC 2616:
289
+ #
290
+ # day-of-week, DD month-name CCYY hh:mm:ss GMT
291
+ #
292
+ # Note that the result is always UTC (GMT).
293
+ #
294
+ # require 'time'
295
+ #
296
+ # t = Time.now
297
+ # t.httpdate # => "Thu, 06 Oct 2011 02:26:12 GMT"
298
+ #
299
+ # You must require 'time' to use this method.
300
+ #
301
+ def httpdate: () -> String
302
+
303
+ #
304
+ # Returns a string which represents the time as a dateTime defined by XML
305
+ # Schema:
306
+ #
307
+ # CCYY-MM-DDThh:mm:ssTZD
308
+ # CCYY-MM-DDThh:mm:ss.sssTZD
309
+ #
310
+ # where TZD is Z or [+-]hh:mm.
311
+ #
312
+ # If self is a UTC time, Z is used as TZD. [+-]hh:mm is used otherwise.
313
+ #
314
+ # +fractional_digits+ specifies a number of digits to use for fractional
315
+ # seconds. Its default value is 0.
316
+ #
317
+ # require 'time'
318
+ #
319
+ # t = Time.now
320
+ # t.iso8601 # => "2011-10-05T22:26:12-04:00"
321
+ #
322
+ # You must require 'time' to use this method.
323
+ #
324
+ def xmlschema: (?Integer fraction_digits) -> String
325
+
326
+ alias iso8601 xmlschema
327
+ end