e621_export_downloader 0.0.1

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 (78) hide show
  1. checksums.yaml +7 -0
  2. data/.irbrc +14 -0
  3. data/.ruby-version +1 -0
  4. data/LICENSE +21 -0
  5. data/README.md +148 -0
  6. data/Rakefile +8 -0
  7. data/exe/e621-export-downloader +112 -0
  8. data/lib/e621_export_downloader/client/options/builder/parsers.rb +42 -0
  9. data/lib/e621_export_downloader/client/options/builder.rb +44 -0
  10. data/lib/e621_export_downloader/client/options.rb +37 -0
  11. data/lib/e621_export_downloader/client.rb +120 -0
  12. data/lib/e621_export_downloader/constants.rb +17 -0
  13. data/lib/e621_export_downloader/export.rb +128 -0
  14. data/lib/e621_export_downloader/export_helper.rb +83 -0
  15. data/lib/e621_export_downloader/models/pool.rb +69 -0
  16. data/lib/e621_export_downloader/models/post.rb +166 -0
  17. data/lib/e621_export_downloader/models/tag.rb +41 -0
  18. data/lib/e621_export_downloader/models/tag_alias.rb +46 -0
  19. data/lib/e621_export_downloader/models/tag_implication.rb +46 -0
  20. data/lib/e621_export_downloader/models/wiki_page.rb +61 -0
  21. data/lib/e621_export_downloader/types.rb +14 -0
  22. data/lib/e621_export_downloader/version.rb +10 -0
  23. data/lib/e621_export_downloader.rb +12 -0
  24. data/sorbet/config +5 -0
  25. data/sorbet/rbi/annotations/.gitattributes +1 -0
  26. data/sorbet/rbi/annotations/faraday.rbi +17 -0
  27. data/sorbet/rbi/annotations/rainbow.rbi +269 -0
  28. data/sorbet/rbi/gems/.gitattributes +1 -0
  29. data/sorbet/rbi/gems/ast@2.4.3.rbi +550 -0
  30. data/sorbet/rbi/gems/benchmark@0.5.0.rbi +621 -0
  31. data/sorbet/rbi/gems/csv@3.3.5.rbi +4462 -0
  32. data/sorbet/rbi/gems/date@3.5.1.rbi +391 -0
  33. data/sorbet/rbi/gems/erb@6.0.4.rbi +1538 -0
  34. data/sorbet/rbi/gems/erubi@1.13.1.rbi +155 -0
  35. data/sorbet/rbi/gems/faraday-net_http@3.4.2.rbi +9 -0
  36. data/sorbet/rbi/gems/faraday@2.14.1.rbi +9 -0
  37. data/sorbet/rbi/gems/io-console@0.8.2.rbi +9 -0
  38. data/sorbet/rbi/gems/json@2.19.5.rbi +2240 -0
  39. data/sorbet/rbi/gems/language_server-protocol@3.17.0.5.rbi +9 -0
  40. data/sorbet/rbi/gems/lint_roller@1.1.0.rbi +189 -0
  41. data/sorbet/rbi/gems/logger@1.7.0.rbi +896 -0
  42. data/sorbet/rbi/gems/net-http@0.9.1.rbi +4029 -0
  43. data/sorbet/rbi/gems/netrc@0.11.0.rbi +147 -0
  44. data/sorbet/rbi/gems/parallel@2.1.0.rbi +321 -0
  45. data/sorbet/rbi/gems/parser@3.3.11.1.rbi +5229 -0
  46. data/sorbet/rbi/gems/pp@0.6.3.rbi +377 -0
  47. data/sorbet/rbi/gems/prettyprint@0.2.0.rbi +455 -0
  48. data/sorbet/rbi/gems/prism@1.9.0.rbi +42224 -0
  49. data/sorbet/rbi/gems/psych@5.3.1.rbi +2374 -0
  50. data/sorbet/rbi/gems/racc@1.8.1.rbi +165 -0
  51. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +362 -0
  52. data/sorbet/rbi/gems/rake@13.4.2.rbi +3130 -0
  53. data/sorbet/rbi/gems/rbi@0.3.11.rbi +5505 -0
  54. data/sorbet/rbi/gems/rbs@4.0.2.rbi +6908 -0
  55. data/sorbet/rbi/gems/rdoc@7.2.0.rbi +9 -0
  56. data/sorbet/rbi/gems/regexp_parser@2.12.0.rbi +3398 -0
  57. data/sorbet/rbi/gems/reline@0.6.3.rbi +2446 -0
  58. data/sorbet/rbi/gems/require-hooks@0.4.0.rbi +152 -0
  59. data/sorbet/rbi/gems/rexml@3.4.4.rbi +4905 -0
  60. data/sorbet/rbi/gems/rubocop-ast@1.49.1.rbi +7062 -0
  61. data/sorbet/rbi/gems/rubocop-rake@0.7.1.rbi +314 -0
  62. data/sorbet/rbi/gems/rubocop@1.86.1.rbi +62227 -0
  63. data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +988 -0
  64. data/sorbet/rbi/gems/rubydex@0.2.0.rbi +663 -0
  65. data/sorbet/rbi/gems/spoom@1.7.13.rbi +6151 -0
  66. data/sorbet/rbi/gems/stringio@3.2.0.rbi +9 -0
  67. data/sorbet/rbi/gems/tapioca@0.19.1.rbi +3555 -0
  68. data/sorbet/rbi/gems/thor@1.5.0.rbi +3870 -0
  69. data/sorbet/rbi/gems/tsort@0.2.0.rbi +389 -0
  70. data/sorbet/rbi/gems/unicode-display_width@3.2.0.rbi +130 -0
  71. data/sorbet/rbi/gems/unicode-emoji@4.2.0.rbi +332 -0
  72. data/sorbet/rbi/gems/uri@1.1.1.rbi +2400 -0
  73. data/sorbet/rbi/gems/zeitwerk@2.7.5.rbi +1090 -0
  74. data/sorbet/rbi/shims/faraday.rbi +42 -0
  75. data/sorbet/rbi/todo.rbi +7 -0
  76. data/sorbet/tapioca/config.yml +13 -0
  77. data/sorbet/tapioca/require.rb +4 -0
  78. metadata +177 -0
@@ -0,0 +1,1538 @@
1
+ # typed: false
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This is an autogenerated file for types exported from the `erb` gem.
5
+ # Please instead update this file by running `bin/tapioca gem erb`.
6
+
7
+
8
+ # :markup: markdown
9
+ #
10
+ # Class **ERB** (the name stands for **Embedded Ruby**)
11
+ # is an easy-to-use, but also very powerful, [template processor][template processor].
12
+ #
13
+ # ## Usage
14
+ #
15
+ # Before you can use \ERB, you must first require it
16
+ # (examples on this page assume that this has been done):
17
+ #
18
+ # ```
19
+ # require 'erb'
20
+ # ```
21
+ #
22
+ # ## In Brief
23
+ #
24
+ # Here's how \ERB works:
25
+ #
26
+ # - You can create a *template*: a plain-text string that includes specially formatted *tags*..
27
+ # - You can create an \ERB object to store the template.
28
+ # - You can call instance method ERB#result to get the *result*.
29
+ #
30
+ # \ERB supports tags of three kinds:
31
+ #
32
+ # - [Expression tags][expression tags]:
33
+ # each begins with `'<%='`, ends with `'%>'`; contains a Ruby expression;
34
+ # in the result, the value of the expression replaces the entire tag:
35
+ #
36
+ # template = 'The magic word is <%= magic_word %>.'
37
+ # erb = ERB.new(template)
38
+ # magic_word = 'xyzzy'
39
+ # erb.result(binding) # => "The magic word is xyzzy."
40
+ #
41
+ # The above call to #result passes argument `binding`,
42
+ # which contains the binding of variable `magic_word` to its string value `'xyzzy'`.
43
+ #
44
+ # The below call to #result need not pass a binding,
45
+ # because its expression `Date::DAYNAMES` is globally defined.
46
+ #
47
+ # ERB.new('Today is <%= Date::DAYNAMES[Date.today.wday] %>.').result # => "Today is Monday."
48
+ #
49
+ # - [Execution tags][execution tags]:
50
+ # each begins with `'<%'`, ends with `'%>'`; contains Ruby code to be executed:
51
+ #
52
+ # template = '<% File.write("t.txt", "Some stuff.") %>'
53
+ # ERB.new(template).result
54
+ # File.read('t.txt') # => "Some stuff."
55
+ #
56
+ # - [Comment tags][comment tags]:
57
+ # each begins with `'<%#'`, ends with `'%>'`; contains comment text;
58
+ # in the result, the entire tag is omitted.
59
+ #
60
+ # template = 'Some stuff;<%# Note to self: figure out what the stuff is. %> more stuff.'
61
+ # ERB.new(template).result # => "Some stuff; more stuff."
62
+ #
63
+ # ## Some Simple Examples
64
+ #
65
+ # Here's a simple example of \ERB in action:
66
+ #
67
+ # ```
68
+ # template = 'The time is <%= Time.now %>.'
69
+ # erb = ERB.new(template)
70
+ # erb.result
71
+ # # => "The time is 2025-09-09 10:49:26 -0500."
72
+ # ```
73
+ #
74
+ # Details:
75
+ #
76
+ # 1. A plain-text string is assigned to variable `template`.
77
+ # Its embedded [expression tag][expression tags] `'<%= Time.now %>'` includes a Ruby expression, `Time.now`.
78
+ # 2. The string is put into a new \ERB object, and stored in variable `erb`.
79
+ # 4. Method call `erb.result` generates a string that contains the run-time value of `Time.now`,
80
+ # as computed at the time of the call.
81
+ #
82
+ # The
83
+ # \ERB object may be re-used:
84
+ #
85
+ # ```
86
+ # erb.result
87
+ # # => "The time is 2025-09-09 10:49:33 -0500."
88
+ # ```
89
+ #
90
+ # Another example:
91
+ #
92
+ # ```
93
+ # template = 'The magic word is <%= magic_word %>.'
94
+ # erb = ERB.new(template)
95
+ # magic_word = 'abracadabra'
96
+ # erb.result(binding)
97
+ # # => "The magic word is abracadabra."
98
+ # ```
99
+ #
100
+ # Details:
101
+ #
102
+ # 1. As before, a plain-text string is assigned to variable `template`.
103
+ # Its embedded [expression tag][expression tags] `'<%= magic_word %>'` has a variable *name*, `magic_word`.
104
+ # 2. The string is put into a new \ERB object, and stored in variable `erb`;
105
+ # note that `magic_word` need not be defined before the \ERB object is created.
106
+ # 3. `magic_word = 'abracadabra'` assigns a value to variable `magic_word`.
107
+ # 4. Method call `erb.result(binding)` generates a string
108
+ # that contains the *value* of `magic_word`.
109
+ #
110
+ # As before, the \ERB object may be re-used:
111
+ #
112
+ # ```
113
+ # magic_word = 'xyzzy'
114
+ # erb.result(binding)
115
+ # # => "The magic word is xyzzy."
116
+ # ```
117
+ #
118
+ # ## Bindings
119
+ #
120
+ # A call to method #result, which produces the formatted result string,
121
+ # requires a [Binding object][binding object] as its argument.
122
+ #
123
+ # The binding object provides the bindings for expressions in [expression tags][expression tags].
124
+ #
125
+ # There are three ways to provide the required binding:
126
+ #
127
+ # - [Default binding][default binding].
128
+ # - [Local binding][local binding].
129
+ # - [Augmented binding][augmented binding]
130
+ #
131
+ # ### Default Binding
132
+ #
133
+ # When you pass no `binding` argument to method #result,
134
+ # the method uses its default binding: the one returned by method #new_toplevel.
135
+ # This binding has the bindings defined by Ruby itself,
136
+ # which are those for Ruby's constants and variables.
137
+ #
138
+ # That binding is sufficient for an expression tag that refers only to Ruby's constants and variables;
139
+ # these expression tags refer only to Ruby's global constant `RUBY_COPYRIGHT` and global variable `$0`:
140
+ #
141
+ # ```
142
+ # template = <<TEMPLATE
143
+ # The Ruby copyright is <%= RUBY_COPYRIGHT.inspect %>.
144
+ # The current process is <%= $0 %>.
145
+ # TEMPLATE
146
+ # puts ERB.new(template).result
147
+ # The Ruby copyright is "ruby - Copyright (C) 1993-2025 Yukihiro Matsumoto".
148
+ # The current process is irb.
149
+ # ```
150
+ #
151
+ # (The current process is `irb` because that's where we're doing these examples!)
152
+ #
153
+ # ### Local Binding
154
+ #
155
+ # The default binding is *not* sufficient for an expression
156
+ # that refers to a a constant or variable that is not defined there:
157
+ #
158
+ # ```
159
+ # Foo = 1 # Defines local constant Foo.
160
+ # foo = 2 # Defines local variable foo.
161
+ # template = <<TEMPLATE
162
+ # The current value of constant Foo is <%= Foo %>.
163
+ # The current value of variable foo is <%= foo %>.
164
+ # The Ruby copyright is <%= RUBY_COPYRIGHT.inspect %>.
165
+ # The current process is <%= $0 %>.
166
+ # TEMPLATE
167
+ # erb = ERB.new(template)
168
+ # ```
169
+ #
170
+ # This call below raises `NameError` because although `Foo` and `foo` are defined locally,
171
+ # they are not defined in the default binding:
172
+ #
173
+ # ```
174
+ # erb.result # Raises NameError.
175
+ # ```
176
+ #
177
+ # To make the locally-defined constants and variables available,
178
+ # you can call #result with the local binding:
179
+ #
180
+ # ```
181
+ # puts erb.result(binding)
182
+ # The current value of constant Foo is 1.
183
+ # The current value of variable foo is 2.
184
+ # The Ruby copyright is "ruby - Copyright (C) 1993-2025 Yukihiro Matsumoto".
185
+ # The current process is irb.
186
+ # ```
187
+ #
188
+ # ### Augmented Binding
189
+ #
190
+ # Another way to make variable bindings (but not constant bindings) available
191
+ # is to use method #result_with_hash(hash);
192
+ # the passed hash has name/value pairs that are to be used to define and assign variables
193
+ # in a copy of the default binding:
194
+ #
195
+ # ```
196
+ # template = <<TEMPLATE
197
+ # The current value of variable bar is <%= bar %>.
198
+ # The current value of variable baz is <%= baz %>.
199
+ # The Ruby copyright is <%= RUBY_COPYRIGHT.inspect %>.
200
+ # The current process is <%= $0 %>.
201
+ # TEMPLATE
202
+ # erb = ERB.new(template)
203
+ # ```
204
+ #
205
+ # Both of these calls raise `NameError`, because `bar` and `baz`
206
+ # are not defined in either the default binding or the local binding.
207
+ #
208
+ # ```
209
+ # puts erb.result # Raises NameError.
210
+ # puts erb.result(binding) # Raises NameError.
211
+ # ```
212
+ #
213
+ # This call passes a hash that causes `bar` and `baz` to be defined
214
+ # in a new binding (derived from #new_toplevel):
215
+ #
216
+ # ```
217
+ # hash = {bar: 3, baz: 4}
218
+ # puts erb.result_with_hash(hash)
219
+ # The current value of variable bar is 3.
220
+ # The current value of variable baz is 4.
221
+ # The Ruby copyright is "ruby - Copyright (C) 1993-2025 Yukihiro Matsumoto".
222
+ # The current process is irb.
223
+ # ```
224
+ #
225
+ # ## Tags
226
+ #
227
+ # The examples above use expression tags.
228
+ # These are the tags available in \ERB:
229
+ #
230
+ # - [Expression tag][expression tags]: the tag contains a Ruby expression;
231
+ # in the result, the entire tag is to be replaced with the run-time value of the expression.
232
+ # - [Execution tag][execution tags]: the tag contains Ruby code;
233
+ # in the result, the entire tag is to be replaced with the run-time value of the code.
234
+ # - [Comment tag][comment tags]: the tag contains comment code;
235
+ # in the result, the entire tag is to be omitted.
236
+ #
237
+ # ### Expression Tags
238
+ #
239
+ # You can embed a Ruby expression in a template using an *expression tag*.
240
+ #
241
+ # Its syntax is `<%= _expression_ %>`,
242
+ # where *expression* is any valid Ruby expression.
243
+ #
244
+ # When you call method #result,
245
+ # the method evaluates the expression and replaces the entire expression tag with the expression's value:
246
+ #
247
+ # ```
248
+ # ERB.new('Today is <%= Date::DAYNAMES[Date.today.wday] %>.').result
249
+ # # => "Today is Monday."
250
+ # ERB.new('Tomorrow will be <%= Date::DAYNAMES[Date.today.wday + 1] %>.').result
251
+ # # => "Tomorrow will be Tuesday."
252
+ # ERB.new('Yesterday was <%= Date::DAYNAMES[Date.today.wday - 1] %>.').result
253
+ # # => "Yesterday was Sunday."
254
+ # ```
255
+ #
256
+ # Note that whitespace before and after the expression
257
+ # is allowed but not required,
258
+ # and that such whitespace is stripped from the result.
259
+ #
260
+ # ```
261
+ # ERB.new('My appointment is on <%=Date::DAYNAMES[Date.today.wday + 2]%>.').result
262
+ # # => "My appointment is on Wednesday."
263
+ # ERB.new('My appointment is on <%= Date::DAYNAMES[Date.today.wday + 2] %>.').result
264
+ # # => "My appointment is on Wednesday."
265
+ # ```
266
+ #
267
+ # ### Execution Tags
268
+ #
269
+ # You can embed Ruby executable code in template using an *execution tag*.
270
+ #
271
+ # Its syntax is `<% _code_ %>`,
272
+ # where *code* is any valid Ruby code.
273
+ #
274
+ # When you call method #result,
275
+ # the method executes the code and removes the entire execution tag
276
+ # (generating no text in the result):
277
+ #
278
+ # ```
279
+ # ERB.new('foo <% Dir.chdir("C:/") %> bar').result # => "foo bar"
280
+ # ```
281
+ #
282
+ # Whitespace before and after the embedded code is optional:
283
+ #
284
+ # ```
285
+ # ERB.new('foo <%Dir.chdir("C:/")%> bar').result # => "foo bar"
286
+ # ```
287
+ #
288
+ # You can interleave text with execution tags to form a control structure
289
+ # such as a conditional, a loop, or a `case` statements.
290
+ #
291
+ # Conditional:
292
+ #
293
+ # ```
294
+ # template = <<TEMPLATE
295
+ # <% if verbosity %>
296
+ # An error has occurred.
297
+ # <% else %>
298
+ # Oops!
299
+ # <% end %>
300
+ # TEMPLATE
301
+ # erb = ERB.new(template)
302
+ # verbosity = true
303
+ # erb.result(binding)
304
+ # # => "\nAn error has occurred.\n\n"
305
+ # verbosity = false
306
+ # erb.result(binding)
307
+ # # => "\nOops!\n\n"
308
+ # ```
309
+ #
310
+ # Note that the interleaved text may itself contain expression tags:
311
+ #
312
+ # Loop:
313
+ #
314
+ # ```
315
+ # template = <<TEMPLATE
316
+ # <% Date::ABBR_DAYNAMES.each do |dayname| %>
317
+ # <%= dayname %>
318
+ # <% end %>
319
+ # TEMPLATE
320
+ # ERB.new(template).result
321
+ # # => "\nSun\n\nMon\n\nTue\n\nWed\n\nThu\n\nFri\n\nSat\n\n"
322
+ # ```
323
+ #
324
+ # Other, non-control, lines of Ruby code may be interleaved with the text,
325
+ # and the Ruby code may itself contain regular Ruby comments:
326
+ #
327
+ # ```
328
+ # template = <<TEMPLATE
329
+ # <% 3.times do %>
330
+ # <%= Time.now %>
331
+ # <% sleep(1) # Let's make the times different. %>
332
+ # <% end %>
333
+ # TEMPLATE
334
+ # ERB.new(template).result
335
+ # # => "\n2025-09-09 11:36:02 -0500\n\n\n2025-09-09 11:36:03 -0500\n\n\n2025-09-09 11:36:04 -0500\n\n\n"
336
+ # ```
337
+ #
338
+ # The execution tag may also contain multiple lines of code:
339
+ #
340
+ # ```
341
+ # template = <<TEMPLATE
342
+ # <%
343
+ # (0..2).each do |i|
344
+ # (0..2).each do |j|
345
+ # %>
346
+ # * <%=i%>,<%=j%>
347
+ # <%
348
+ # end
349
+ # end
350
+ # %>
351
+ # TEMPLATE
352
+ # ERB.new(template).result
353
+ # # => "\n* 0,0\n\n* 0,1\n\n* 0,2\n\n* 1,0\n\n* 1,1\n\n* 1,2\n\n* 2,0\n\n* 2,1\n\n* 2,2\n\n"
354
+ # ```
355
+ #
356
+ # #### Shorthand Format for Execution Tags
357
+ #
358
+ # You can use keyword argument `trim_mode: '%'` to enable a shorthand format for execution tags;
359
+ # this example uses the shorthand format `% _code_` instead of `<% _code_ %>`:
360
+ #
361
+ # ```
362
+ # template = <<TEMPLATE
363
+ # % priorities.each do |priority|
364
+ # * <%= priority %>
365
+ # % end
366
+ # TEMPLATE
367
+ # erb = ERB.new(template, trim_mode: '%')
368
+ # priorities = [ 'Run Ruby Quiz',
369
+ # 'Document Modules',
370
+ # 'Answer Questions on Ruby Talk' ]
371
+ # puts erb.result(binding)
372
+ # * Run Ruby Quiz
373
+ # * Document Modules
374
+ # * Answer Questions on Ruby Talk
375
+ # ```
376
+ #
377
+ # Note that in the shorthand format, the character `'%'` must be the first character in the code line
378
+ # (no leading whitespace).
379
+ #
380
+ # #### Suppressing Unwanted Blank Lines
381
+ #
382
+ # With keyword argument `trim_mode` not given,
383
+ # all blank lines go into the result:
384
+ #
385
+ # ```
386
+ # template = <<TEMPLATE
387
+ # <% if true %>
388
+ # <%= RUBY_VERSION %>
389
+ # <% end %>
390
+ # TEMPLATE
391
+ # ERB.new(template).result.lines.each {|line| puts line.inspect }
392
+ # "\n"
393
+ # "3.4.5\n"
394
+ # "\n"
395
+ # ```
396
+ #
397
+ # You can give `trim_mode: '-'`, you can suppress each blank line
398
+ # whose source line ends with `-%>` (instead of `%>`):
399
+ #
400
+ # ```
401
+ # template = <<TEMPLATE
402
+ # <% if true -%>
403
+ # <%= RUBY_VERSION %>
404
+ # <% end -%>
405
+ # TEMPLATE
406
+ # ERB.new(template, trim_mode: '-').result.lines.each {|line| puts line.inspect }
407
+ # "3.4.5\n"
408
+ # ```
409
+ #
410
+ # It is an error to use the trailing `'-%>'` notation without `trim_mode: '-'`:
411
+ #
412
+ # ```
413
+ # ERB.new(template).result.lines.each {|line| puts line.inspect } # Raises SyntaxError.
414
+ # ```
415
+ #
416
+ # #### Suppressing Unwanted Newlines
417
+ #
418
+ # Consider this template:
419
+ #
420
+ # ```
421
+ # template = <<TEMPLATE
422
+ # <% RUBY_VERSION %>
423
+ # <%= RUBY_VERSION %>
424
+ # foo <% RUBY_VERSION %>
425
+ # foo <%= RUBY_VERSION %>
426
+ # TEMPLATE
427
+ # ```
428
+ #
429
+ # With keyword argument `trim_mode` not given, all newlines go into the result:
430
+ #
431
+ # ```
432
+ # ERB.new(template).result.lines.each {|line| puts line.inspect }
433
+ # "\n"
434
+ # "3.4.5\n"
435
+ # "foo \n"
436
+ # "foo 3.4.5\n"
437
+ # ```
438
+ #
439
+ # You can give `trim_mode: '>'` to suppress the trailing newline
440
+ # for each line that ends with `'%>'` (regardless of its beginning):
441
+ #
442
+ # ```
443
+ # ERB.new(template, trim_mode: '>').result.lines.each {|line| puts line.inspect }
444
+ # "3.4.5foo foo 3.4.5"
445
+ # ```
446
+ #
447
+ # You can give `trim_mode: '<>'` to suppress the trailing newline
448
+ # for each line that both begins with `'<%'` and ends with `'%>'`:
449
+ #
450
+ # ```
451
+ # ERB.new(template, trim_mode: '<>').result.lines.each {|line| puts line.inspect }
452
+ # "3.4.5foo \n"
453
+ # "foo 3.4.5\n"
454
+ # ```
455
+ #
456
+ # #### Combining Trim Modes
457
+ #
458
+ # You can combine certain trim modes:
459
+ #
460
+ # - `'%-'`: Enable shorthand and omit each blank line ending with `'-%>'`.
461
+ # - `'%>'`: Enable shorthand and omit newline for each line ending with `'%>'`.
462
+ # - `'%<>'`: Enable shorthand and omit newline for each line starting with `'<%'` and ending with `'%>'`.
463
+ #
464
+ # ### Comment Tags
465
+ #
466
+ # You can embed a comment in a template using a *comment tag*;
467
+ # its syntax is `<%# _text_ %>`,
468
+ # where *text* is the text of the comment.
469
+ #
470
+ # When you call method #result,
471
+ # it removes the entire comment tag
472
+ # (generating no text in the result).
473
+ #
474
+ # Example:
475
+ #
476
+ # ```
477
+ # template = 'Some stuff;<%# Note to self: figure out what the stuff is. %> more stuff.'
478
+ # ERB.new(template).result # => "Some stuff; more stuff."
479
+ # ```
480
+ #
481
+ # A comment tag may appear anywhere in the template.
482
+ #
483
+ # Note that the beginning of the tag must be `'<%#'`, not `'<% #'`.
484
+ #
485
+ # In this example, the tag begins with `'<% #'`, and so is an execution tag, not a comment tag;
486
+ # the cited code consists entirely of a Ruby-style comment (which is of course ignored):
487
+ #
488
+ # ```
489
+ # ERB.new('Some stuff;<% # Note to self: figure out what the stuff is. %> more stuff.').result
490
+ # # => "Some stuff;"
491
+ # ```
492
+ #
493
+ # ## Encodings
494
+ #
495
+ # An \ERB object has an [encoding][encoding],
496
+ # which is by default the encoding of the template string;
497
+ # the result string will also have that encoding.
498
+ #
499
+ # ```
500
+ # template = <<TEMPLATE
501
+ # <%# Comment. %>
502
+ # TEMPLATE
503
+ # erb = ERB.new(template)
504
+ # template.encoding # => #<Encoding:UTF-8>
505
+ # erb.encoding # => #<Encoding:UTF-8>
506
+ # erb.result.encoding # => #<Encoding:UTF-8>
507
+ # ```
508
+ #
509
+ # You can specify a different encoding by adding a [magic comment][magic comments]
510
+ # at the top of the given template:
511
+ #
512
+ # ```
513
+ # template = <<TEMPLATE
514
+ # <%#-*- coding: Big5 -*-%>
515
+ # <%# Comment. %>
516
+ # TEMPLATE
517
+ # erb = ERB.new(template)
518
+ # template.encoding # => #<Encoding:UTF-8>
519
+ # erb.encoding # => #<Encoding:Big5>
520
+ # erb.result.encoding # => #<Encoding:Big5>
521
+ # ```
522
+ #
523
+ # ## Error Reporting
524
+ #
525
+ # Consider this template (containing an error):
526
+ #
527
+ # ```
528
+ # template = '<%= nosuch %>'
529
+ # erb = ERB.new(template)
530
+ # ```
531
+ #
532
+ # When \ERB reports an error,
533
+ # it includes a file name (if available) and a line number;
534
+ # the file name comes from method #filename, the line number from method #lineno.
535
+ #
536
+ # Initially, those values are `nil` and `0`, respectively;
537
+ # these initial values are reported as `'(erb)'` and `1`, respectively:
538
+ #
539
+ # ```
540
+ # erb.filename # => nil
541
+ # erb.lineno # => 0
542
+ # erb.result
543
+ # (erb):1:in '<main>': undefined local variable or method 'nosuch' for main (NameError)
544
+ # ```
545
+ #
546
+ # You can use methods #filename= and #lineno= to assign values
547
+ # that are more meaningful in your context:
548
+ #
549
+ # ```
550
+ # erb.filename = 't.txt'
551
+ # erb.lineno = 555
552
+ # erb.result
553
+ # t.txt:556:in '<main>': undefined local variable or method 'nosuch' for main (NameError)
554
+ # ```
555
+ #
556
+ # You can use method #location= to set both values:
557
+ #
558
+ # ```
559
+ # erb.location = ['u.txt', 999]
560
+ # erb.result
561
+ # u.txt:1000:in '<main>': undefined local variable or method 'nosuch' for main (NameError)
562
+ # ```
563
+ #
564
+ # ## Plain Text with Embedded Ruby
565
+ #
566
+ # Here's a plain-text template;
567
+ # it uses the literal notation `'%q{ ... }'` to define the template
568
+ # (see [%q literals][%q literals]);
569
+ # this avoids problems with backslashes.
570
+ #
571
+ # ```
572
+ # template = %q{
573
+ # From: James Edward Gray II <james@grayproductions.net>
574
+ # To: <%= to %>
575
+ # Subject: Addressing Needs
576
+ #
577
+ # <%= to[/\w+/] %>:
578
+ #
579
+ # Just wanted to send a quick note assuring that your needs are being
580
+ # addressed.
581
+ #
582
+ # I want you to know that my team will keep working on the issues,
583
+ # especially:
584
+ #
585
+ # <%# ignore numerous minor requests -- focus on priorities %>
586
+ # % priorities.each do |priority|
587
+ # * <%= priority %>
588
+ # % end
589
+ #
590
+ # Thanks for your patience.
591
+ #
592
+ # James Edward Gray II
593
+ # }
594
+ # ```
595
+ #
596
+ # The template will need these:
597
+ #
598
+ # ```
599
+ # to = 'Community Spokesman <spokesman@ruby_community.org>'
600
+ # priorities = [ 'Run Ruby Quiz',
601
+ # 'Document Modules',
602
+ # 'Answer Questions on Ruby Talk' ]
603
+ # ```
604
+ #
605
+ # Finally, create the \ERB object and get the result
606
+ #
607
+ # ```
608
+ # erb = ERB.new(template, trim_mode: '%<>')
609
+ # puts erb.result(binding)
610
+ #
611
+ # From: James Edward Gray II <james@grayproductions.net>
612
+ # To: Community Spokesman <spokesman@ruby_community.org>
613
+ # Subject: Addressing Needs
614
+ #
615
+ # Community:
616
+ #
617
+ # Just wanted to send a quick note assuring that your needs are being
618
+ # addressed.
619
+ #
620
+ # I want you to know that my team will keep working on the issues,
621
+ # especially:
622
+ #
623
+ # * Run Ruby Quiz
624
+ # * Document Modules
625
+ # * Answer Questions on Ruby Talk
626
+ #
627
+ # Thanks for your patience.
628
+ #
629
+ # James Edward Gray II
630
+ # ```
631
+ #
632
+ # ## HTML with Embedded Ruby
633
+ #
634
+ # This example shows an HTML template.
635
+ #
636
+ # First, here's a custom class, `Product`:
637
+ #
638
+ # ```
639
+ # class Product
640
+ # def initialize(code, name, desc, cost)
641
+ # @code = code
642
+ # @name = name
643
+ # @desc = desc
644
+ # @cost = cost
645
+ # @features = []
646
+ # end
647
+ #
648
+ # def add_feature(feature)
649
+ # @features << feature
650
+ # end
651
+ #
652
+ # # Support templating of member data.
653
+ # def get_binding
654
+ # binding
655
+ # end
656
+ #
657
+ # end
658
+ # ```
659
+ #
660
+ # The template below will need these values:
661
+ #
662
+ # ```
663
+ # toy = Product.new('TZ-1002',
664
+ # 'Rubysapien',
665
+ # "Geek's Best Friend! Responds to Ruby commands...",
666
+ # 999.95
667
+ # )
668
+ # toy.add_feature('Listens for verbal commands in the Ruby language!')
669
+ # toy.add_feature('Ignores Perl, Java, and all C variants.')
670
+ # toy.add_feature('Karate-Chop Action!!!')
671
+ # toy.add_feature('Matz signature on left leg.')
672
+ # toy.add_feature('Gem studded eyes... Rubies, of course!')
673
+ # ```
674
+ #
675
+ # Here's the HTML:
676
+ #
677
+ # ```
678
+ # template = <<TEMPLATE
679
+ # <html>
680
+ # <head><title>Ruby Toys -- <%= @name %></title></head>
681
+ # <body>
682
+ # <h1><%= @name %> (<%= @code %>)</h1>
683
+ # <p><%= @desc %></p>
684
+ # <ul>
685
+ # <% @features.each do |f| %>
686
+ # <li><b><%= f %></b></li>
687
+ # <% end %>
688
+ # </ul>
689
+ # <p>
690
+ # <% if @cost < 10 %>
691
+ # <b>Only <%= @cost %>!!!</b>
692
+ # <% else %>
693
+ # Call for a price, today!
694
+ # <% end %>
695
+ # </p>
696
+ # </body>
697
+ # </html>
698
+ # TEMPLATE
699
+ # ```
700
+ #
701
+ # Finally, create the \ERB object and get the result (omitting some blank lines):
702
+ #
703
+ # ```
704
+ # erb = ERB.new(template)
705
+ # puts erb.result(toy.get_binding)
706
+ # <html>
707
+ # <head><title>Ruby Toys -- Rubysapien</title></head>
708
+ # <body>
709
+ # <h1>Rubysapien (TZ-1002)</h1>
710
+ # <p>Geek's Best Friend! Responds to Ruby commands...</p>
711
+ # <ul>
712
+ # <li><b>Listens for verbal commands in the Ruby language!</b></li>
713
+ # <li><b>Ignores Perl, Java, and all C variants.</b></li>
714
+ # <li><b>Karate-Chop Action!!!</b></li>
715
+ # <li><b>Matz signature on left leg.</b></li>
716
+ # <li><b>Gem studded eyes... Rubies, of course!</b></li>
717
+ # </ul>
718
+ # <p>
719
+ # Call for a price, today!
720
+ # </p>
721
+ # </body>
722
+ # </html>
723
+ # ```
724
+ #
725
+ #
726
+ # ## Other Template Processors
727
+ #
728
+ # Various Ruby projects have their own template processors.
729
+ # The Ruby Processing System [RDoc][rdoc], for example, has one that can be used elsewhere.
730
+ #
731
+ # Other popular template processors may found in the [Template Engines][template engines] page
732
+ # of the Ruby Toolbox.
733
+ #
734
+ # [%q literals]: https://docs.ruby-lang.org/en/master/syntax/literals_rdoc.html#label-25q-3A+Non-Interpolable+String+Literals
735
+ # [augmented binding]: rdoc-ref:ERB@Augmented+Binding
736
+ # [binding object]: https://docs.ruby-lang.org/en/master/Binding.html
737
+ # [comment tags]: rdoc-ref:ERB@Comment+Tags
738
+ # [default binding]: rdoc-ref:ERB@Default+Binding
739
+ # [encoding]: https://docs.ruby-lang.org/en/master/Encoding.html
740
+ # [execution tags]: rdoc-ref:ERB@Execution+Tags
741
+ # [expression tags]: rdoc-ref:ERB@Expression+Tags
742
+ # [kernel#binding]: https://docs.ruby-lang.org/en/master/Kernel.html#method-i-binding
743
+ # [local binding]: rdoc-ref:ERB@Local+Binding
744
+ # [magic comments]: https://docs.ruby-lang.org/en/master/syntax/comments_rdoc.html#label-Magic+Comments
745
+ # [rdoc]: https://ruby.github.io/rdoc
746
+ # [sprintf]: https://docs.ruby-lang.org/en/master/Kernel.html#method-i-sprintf
747
+ # [template engines]: https://www.ruby-toolbox.com/categories/template_engines
748
+ # [template processor]: https://en.wikipedia.org/wiki/Template_processor
749
+ #
750
+ # pkg:gem/erb#lib/erb/version.rb:2
751
+ class ERB
752
+ # :markup: markdown
753
+ #
754
+ # :call-seq:
755
+ # ERB.new(template, trim_mode: nil, eoutvar: '_erbout')
756
+ #
757
+ # Returns a new \ERB object containing the given string +template+.
758
+ #
759
+ # For details about `template`, its embedded tags, and generated results, see ERB.
760
+ #
761
+ # **Keyword Argument `trim_mode`**
762
+ #
763
+ # You can use keyword argument `trim_mode: '%'`
764
+ # to enable the [shorthand format][shorthand format] for execution tags.
765
+ #
766
+ # This value allows [blank line control][blank line control]:
767
+ #
768
+ # - `'-'`: Omit each blank line ending with `'%>'`.
769
+ #
770
+ # Other values allow [newline control][newline control]:
771
+ #
772
+ # - `'>'`: Omit newline for each line ending with `'%>'`.
773
+ # - `'<>'`: Omit newline for each line starting with `'<%'` and ending with `'%>'`.
774
+ #
775
+ # You can also [combine trim modes][combine trim modes].
776
+ #
777
+ # **Keyword Argument `eoutvar`**
778
+ #
779
+ # The string value of keyword argument `eoutvar` specifies the name of the variable
780
+ # that method #result uses to construct its result string;
781
+ # see #src.
782
+ #
783
+ # This is useful when you need to run multiple \ERB templates through the same binding
784
+ # and/or when you want to control where output ends up.
785
+ #
786
+ # It's good practice to choose a variable name that begins with an underscore: `'_'`.
787
+ #
788
+ # [blank line control]: rdoc-ref:ERB@Suppressing+Unwanted+Blank+Lines
789
+ # [combine trim modes]: rdoc-ref:ERB@Combining+Trim+Modes
790
+ # [newline control]: rdoc-ref:ERB@Suppressing+Unwanted+Newlines
791
+ # [shorthand format]: rdoc-ref:ERB@Shorthand+Format+for+Execution+Tags
792
+ #
793
+ # pkg:gem/erb#lib/erb.rb:832
794
+ def initialize(str, trim_mode: T.unsafe(nil), eoutvar: T.unsafe(nil)); end
795
+
796
+ # :markup: markdown
797
+ #
798
+ # :call-seq:
799
+ # def_class(super_class = Object, method_name = 'result') -> new_class
800
+ #
801
+ # Returns a new nameless class whose superclass is `super_class`,
802
+ # and which has instance method `method_name`.
803
+ #
804
+ # Create a template from HTML that has embedded expression tags that use `@arg1` and `@arg2`:
805
+ #
806
+ # ```
807
+ # html = <<TEMPLATE
808
+ # <html>
809
+ # <body>
810
+ # <p><%= @arg1 %></p>
811
+ # <p><%= @arg2 %></p>
812
+ # </body>
813
+ # </html>
814
+ # TEMPLATE
815
+ # template = ERB.new(html)
816
+ # ```
817
+ #
818
+ # Create a base class that has `@arg1` and `@arg2`:
819
+ #
820
+ # ```
821
+ # class MyBaseClass
822
+ # def initialize(arg1, arg2)
823
+ # @arg1 = arg1
824
+ # @arg2 = arg2
825
+ # end
826
+ # end
827
+ # ```
828
+ #
829
+ # Use method #def_class to create a subclass that has method `:render`:
830
+ #
831
+ # ```
832
+ # MySubClass = template.def_class(MyBaseClass, :render)
833
+ # ```
834
+ #
835
+ # Generate the result:
836
+ #
837
+ # ```
838
+ # puts MySubClass.new('foo', 123).render
839
+ # <html>
840
+ # <body>
841
+ # <p>foo</p>
842
+ # <p>123</p>
843
+ # </body>
844
+ # </html>
845
+ # ```
846
+ #
847
+ # pkg:gem/erb#lib/erb.rb:1174
848
+ def def_class(superklass = T.unsafe(nil), methodname = T.unsafe(nil)); end
849
+
850
+ # :markup: markdown
851
+ #
852
+ # :call-seq:
853
+ # def_method(module, method_signature, filename = '(ERB)') -> method_name
854
+ #
855
+ # Creates and returns a new instance method in the given module `module`;
856
+ # returns the method name as a symbol.
857
+ #
858
+ # The method is created from the given `method_signature`,
859
+ # which consists of the method name and its argument names (if any).
860
+ #
861
+ # The `filename` sets the value of #filename;
862
+ # see [Error Reporting][error reporting].
863
+ #
864
+ # [error reporting]: rdoc-ref:ERB@Error+Reporting
865
+ #
866
+ # ```
867
+ # template = '<%= arg1 %> <%= arg2 %>'
868
+ # erb = ERB.new(template)
869
+ # MyModule = Module.new
870
+ # erb.def_method(MyModule, 'render(arg1, arg2)') # => :render
871
+ # class MyClass; include MyModule; end
872
+ # MyClass.new.render('foo', 123) # => "foo 123"
873
+ # ```
874
+ #
875
+ # pkg:gem/erb#lib/erb.rb:1089
876
+ def def_method(mod, methodname, fname = T.unsafe(nil)); end
877
+
878
+ # :markup: markdown
879
+ #
880
+ # :call-seq:
881
+ # def_module(method_name = 'erb') -> new_module
882
+ #
883
+ # Returns a new nameless module that has instance method `method_name`.
884
+ #
885
+ # ```
886
+ # template = '<%= arg1 %> <%= arg2 %>'
887
+ # erb = ERB.new(template)
888
+ # MyModule = template.def_module('render(arg1, arg2)')
889
+ # class MyClass
890
+ # include MyModule
891
+ # end
892
+ # MyClass.new.render('foo', 123)
893
+ # # => "foo 123"
894
+ # ```
895
+ #
896
+ # pkg:gem/erb#lib/erb.rb:1117
897
+ def def_module(methodname = T.unsafe(nil)); end
898
+
899
+ # :markup: markdown
900
+ #
901
+ # Returns the encoding of `self`;
902
+ # see [Encodings][encodings]:
903
+ #
904
+ # [encodings]: rdoc-ref:ERB@Encodings
905
+ #
906
+ # pkg:gem/erb#lib/erb.rb:910
907
+ def encoding; end
908
+
909
+ # :markup: markdown
910
+ #
911
+ # Sets or returns the file name to be used in reporting errors;
912
+ # see [Error Reporting][error reporting].
913
+ #
914
+ # [error reporting]: rdoc-ref:ERB@Error+Reporting
915
+ #
916
+ # pkg:gem/erb#lib/erb.rb:918
917
+ def filename; end
918
+
919
+ # :markup: markdown
920
+ #
921
+ # Sets or returns the file name to be used in reporting errors;
922
+ # see [Error Reporting][error reporting].
923
+ #
924
+ # [error reporting]: rdoc-ref:ERB@Error+Reporting
925
+ #
926
+ # pkg:gem/erb#lib/erb.rb:918
927
+ def filename=(_arg0); end
928
+
929
+ # :markup: markdown
930
+ #
931
+ # Sets or returns the line number to be used in reporting errors;
932
+ # see [Error Reporting][error reporting].
933
+ #
934
+ # [error reporting]: rdoc-ref:ERB@Error+Reporting
935
+ #
936
+ # pkg:gem/erb#lib/erb.rb:926
937
+ def lineno; end
938
+
939
+ # :markup: markdown
940
+ #
941
+ # Sets or returns the line number to be used in reporting errors;
942
+ # see [Error Reporting][error reporting].
943
+ #
944
+ # [error reporting]: rdoc-ref:ERB@Error+Reporting
945
+ #
946
+ # pkg:gem/erb#lib/erb.rb:926
947
+ def lineno=(_arg0); end
948
+
949
+ # :markup: markdown
950
+ #
951
+ # :call-seq:
952
+ # location = [filename, lineno] => [filename, lineno]
953
+ # location = filename -> filename
954
+ #
955
+ # Sets the values of #filename and, if given, #lineno;
956
+ # see [Error Reporting][error reporting].
957
+ #
958
+ # [error reporting]: rdoc-ref:ERB@Error+Reporting
959
+ #
960
+ # pkg:gem/erb#lib/erb.rb:938
961
+ def location=(_arg0); end
962
+
963
+ # :markup: markdown
964
+ #
965
+ # :call-seq:
966
+ # make_compiler -> erb_compiler
967
+ #
968
+ # Returns a new ERB::Compiler with the given `trim_mode`;
969
+ # for `trim_mode` values, see ERB.new:
970
+ #
971
+ # ```
972
+ # ERB.new('').make_compiler(nil)
973
+ # # => #<ERB::Compiler:0x000001cff9467678 @insert_cmd="print", @percent=false, @post_cmd=[], @pre_cmd=[], @put_cmd="print", @trim_mode=nil>
974
+ # ```
975
+ #
976
+ # pkg:gem/erb#lib/erb.rb:855
977
+ def make_compiler(trim_mode); end
978
+
979
+ # :markup: markdown
980
+ #
981
+ # :call-seq:
982
+ # result(binding = new_toplevel) -> new_string
983
+ #
984
+ # Returns the string result formed by processing \ERB tags found in the stored template in `self`.
985
+ #
986
+ # With no argument given, uses the default binding;
987
+ # see [Default Binding][default binding].
988
+ #
989
+ # With argument `binding` given, uses the local binding;
990
+ # see [Local Binding][local binding].
991
+ #
992
+ # See also #result_with_hash.
993
+ #
994
+ # [default binding]: rdoc-ref:ERB@Default+Binding
995
+ # [local binding]: rdoc-ref:ERB@Local+Binding
996
+ #
997
+ # pkg:gem/erb#lib/erb.rb:1009
998
+ def result(b = T.unsafe(nil)); end
999
+
1000
+ # :markup: markdown
1001
+ #
1002
+ # :call-seq:
1003
+ # result_with_hash(hash) -> new_string
1004
+ #
1005
+ # Returns the string result formed by processing \ERB tags found in the stored string in `self`;
1006
+ # see [Augmented Binding][augmented binding].
1007
+ #
1008
+ # See also #result.
1009
+ #
1010
+ # [augmented binding]: rdoc-ref:ERB@Augmented+Binding
1011
+ #
1012
+ # pkg:gem/erb#lib/erb.rb:1028
1013
+ def result_with_hash(hash); end
1014
+
1015
+ # :markup: markdown
1016
+ #
1017
+ # :call-seq:
1018
+ # run(binding = new_toplevel) -> nil
1019
+ #
1020
+ # Like #result, but prints the result string (instead of returning it);
1021
+ # returns `nil`.
1022
+ #
1023
+ # pkg:gem/erb#lib/erb.rb:987
1024
+ def run(b = T.unsafe(nil)); end
1025
+
1026
+ # :markup: markdown
1027
+ #
1028
+ # :call-seq:
1029
+ # set_eoutvar(compiler, eoutvar = '_erbout') -> [eoutvar]
1030
+ #
1031
+ # Sets the `eoutvar` value in the ERB::Compiler object `compiler`;
1032
+ # returns a 1-element array containing the value of `eoutvar`:
1033
+ #
1034
+ # ```
1035
+ # template = ERB.new('')
1036
+ # compiler = template.make_compiler(nil)
1037
+ # pp compiler
1038
+ # #<ERB::Compiler:0x000001cff8a9aa00
1039
+ # @insert_cmd="print",
1040
+ # @percent=false,
1041
+ # @post_cmd=[],
1042
+ # @pre_cmd=[],
1043
+ # @put_cmd="print",
1044
+ # @trim_mode=nil>
1045
+ # template.set_eoutvar(compiler, '_foo') # => ["_foo"]
1046
+ # pp compiler
1047
+ # #<ERB::Compiler:0x000001cff8a9aa00
1048
+ # @insert_cmd="_foo.<<",
1049
+ # @percent=false,
1050
+ # @post_cmd=["_foo"],
1051
+ # @pre_cmd=["_foo = +''"],
1052
+ # @put_cmd="_foo.<<",
1053
+ # @trim_mode=nil>
1054
+ # ```
1055
+ #
1056
+ # pkg:gem/erb#lib/erb.rb:973
1057
+ def set_eoutvar(compiler, eoutvar = T.unsafe(nil)); end
1058
+
1059
+ # :markup: markdown
1060
+ #
1061
+ # Returns the Ruby code that, when executed, generates the result;
1062
+ # the code is executed by method #result,
1063
+ # and by its wrapper methods #result_with_hash and #run:
1064
+ #
1065
+ # ```
1066
+ # template = 'The time is <%= Time.now %>.'
1067
+ # erb = ERB.new(template)
1068
+ # erb.src
1069
+ # # => "#coding:UTF-8\n_erbout = +''; _erbout.<< \"The time is \".freeze; _erbout.<<(( Time.now ).to_s); _erbout.<< \".\".freeze; _erbout"
1070
+ # erb.result
1071
+ # # => "The time is 2025-09-18 15:58:08 -0500."
1072
+ # ```
1073
+ #
1074
+ # In a more readable format:
1075
+ #
1076
+ # ```
1077
+ # # puts erb.src.split('; ')
1078
+ # # #coding:UTF-8
1079
+ # # _erbout = +''
1080
+ # # _erbout.<< "The time is ".freeze
1081
+ # # _erbout.<<(( Time.now ).to_s)
1082
+ # # _erbout.<< ".".freeze
1083
+ # # _erbout
1084
+ # ```
1085
+ #
1086
+ # Variable `_erbout` is used to store the intermediate results in the code;
1087
+ # the name `_erbout` is the default in ERB.new,
1088
+ # and can be changed via keyword argument `eoutvar`:
1089
+ #
1090
+ # ```
1091
+ # erb = ERB.new(template, eoutvar: '_foo')
1092
+ # puts template.src.split('; ')
1093
+ # #coding:UTF-8
1094
+ # _foo = +''
1095
+ # _foo.<< "The time is ".freeze
1096
+ # _foo.<<(( Time.now ).to_s)
1097
+ # _foo.<< ".".freeze
1098
+ # _foo
1099
+ # ```
1100
+ #
1101
+ # pkg:gem/erb#lib/erb.rb:901
1102
+ def src; end
1103
+
1104
+ private
1105
+
1106
+ # :markup: markdown
1107
+ #
1108
+ # :call-seq:
1109
+ # new_toplevel(symbols) -> new_binding
1110
+ #
1111
+ # Returns a new binding based on `TOPLEVEL_BINDING`;
1112
+ # used to create a default binding for a call to #result.
1113
+ #
1114
+ # See [Default Binding][default binding].
1115
+ #
1116
+ # Argument `symbols` is an array of symbols;
1117
+ # each symbol `symbol` is defined as a new variable to hide and
1118
+ # prevent it from overwriting a variable of the same name already
1119
+ # defined within the binding.
1120
+ #
1121
+ # [default binding]: rdoc-ref:ERB@Default+Binding
1122
+ #
1123
+ # pkg:gem/erb#lib/erb.rb:1052
1124
+ def new_toplevel(vars = T.unsafe(nil)); end
1125
+
1126
+ class << self
1127
+ # :markup: markdown
1128
+ #
1129
+ # :call-seq:
1130
+ # self.version -> string
1131
+ #
1132
+ # Returns the string \ERB version.
1133
+ #
1134
+ # pkg:gem/erb#lib/erb.rb:787
1135
+ def version; end
1136
+ end
1137
+ end
1138
+
1139
+ # --
1140
+ # ERB::Compiler
1141
+ #
1142
+ # Compiles ERB templates into Ruby code; the compiled code produces the
1143
+ # template result when evaluated. ERB::Compiler provides hooks to define how
1144
+ # generated output is handled.
1145
+ #
1146
+ # Internally ERB does something like this to generate the code returned by
1147
+ # ERB#src:
1148
+ #
1149
+ # compiler = ERB::Compiler.new('<>')
1150
+ # compiler.pre_cmd = ["_erbout=+''"]
1151
+ # compiler.put_cmd = "_erbout.<<"
1152
+ # compiler.insert_cmd = "_erbout.<<"
1153
+ # compiler.post_cmd = ["_erbout"]
1154
+ #
1155
+ # code, enc = compiler.compile("Got <%= obj %>!\n")
1156
+ # puts code
1157
+ #
1158
+ # <i>Generates</i>:
1159
+ #
1160
+ # #coding:UTF-8
1161
+ # _erbout=+''; _erbout.<< "Got ".freeze; _erbout.<<(( obj ).to_s); _erbout.<< "!\n".freeze; _erbout
1162
+ #
1163
+ # By default the output is sent to the print method. For example:
1164
+ #
1165
+ # compiler = ERB::Compiler.new('<>')
1166
+ # code, enc = compiler.compile("Got <%= obj %>!\n")
1167
+ # puts code
1168
+ #
1169
+ # <i>Generates</i>:
1170
+ #
1171
+ # #coding:UTF-8
1172
+ # print "Got ".freeze; print(( obj ).to_s); print "!\n".freeze
1173
+ #
1174
+ # == Evaluation
1175
+ #
1176
+ # The compiled code can be used in any context where the names in the code
1177
+ # correctly resolve. Using the last example, each of these print 'Got It!'
1178
+ #
1179
+ # Evaluate using a variable:
1180
+ #
1181
+ # obj = 'It'
1182
+ # eval code
1183
+ #
1184
+ # Evaluate using an input:
1185
+ #
1186
+ # mod = Module.new
1187
+ # mod.module_eval %{
1188
+ # def get(obj)
1189
+ # #{code}
1190
+ # end
1191
+ # }
1192
+ # extend mod
1193
+ # get('It')
1194
+ #
1195
+ # Evaluate using an accessor:
1196
+ #
1197
+ # klass = Class.new Object
1198
+ # klass.class_eval %{
1199
+ # attr_accessor :obj
1200
+ # def initialize(obj)
1201
+ # @obj = obj
1202
+ # end
1203
+ # def get_it
1204
+ # #{code}
1205
+ # end
1206
+ # }
1207
+ # klass.new('It').get_it
1208
+ #
1209
+ # Good! See also ERB#def_method, ERB#def_module, and ERB#def_class.
1210
+ #
1211
+ # pkg:gem/erb#lib/erb/compiler.rb:73
1212
+ class ERB::Compiler
1213
+ # Construct a new compiler using the trim_mode. See ERB::new for available
1214
+ # trim modes.
1215
+ #
1216
+ # pkg:gem/erb#lib/erb/compiler.rb:433
1217
+ def initialize(trim_mode); end
1218
+
1219
+ # pkg:gem/erb#lib/erb/compiler.rb:315
1220
+ def add_insert_cmd(out, content); end
1221
+
1222
+ # pkg:gem/erb#lib/erb/compiler.rb:311
1223
+ def add_put_cmd(out, content); end
1224
+
1225
+ # Compiles an ERB template into Ruby code. Returns an array of the code
1226
+ # and encoding like ["code", Encoding].
1227
+ #
1228
+ # pkg:gem/erb#lib/erb/compiler.rb:321
1229
+ def compile(s); end
1230
+
1231
+ # pkg:gem/erb#lib/erb/compiler.rb:381
1232
+ def compile_content(stag, out); end
1233
+
1234
+ # pkg:gem/erb#lib/erb/compiler.rb:368
1235
+ def compile_etag(etag, out, scanner); end
1236
+
1237
+ # pkg:gem/erb#lib/erb/compiler.rb:344
1238
+ def compile_stag(stag, out, scanner); end
1239
+
1240
+ # The command to handle text that is inserted prior to a newline
1241
+ #
1242
+ # pkg:gem/erb#lib/erb/compiler.rb:446
1243
+ def insert_cmd; end
1244
+
1245
+ # The command to handle text that is inserted prior to a newline
1246
+ #
1247
+ # pkg:gem/erb#lib/erb/compiler.rb:446
1248
+ def insert_cmd=(_arg0); end
1249
+
1250
+ # pkg:gem/erb#lib/erb/compiler.rb:427
1251
+ def make_scanner(src); end
1252
+
1253
+ # pkg:gem/erb#lib/erb/compiler.rb:440
1254
+ def percent; end
1255
+
1256
+ # An array of commands appended to compiled code
1257
+ #
1258
+ # pkg:gem/erb#lib/erb/compiler.rb:452
1259
+ def post_cmd; end
1260
+
1261
+ # An array of commands appended to compiled code
1262
+ #
1263
+ # pkg:gem/erb#lib/erb/compiler.rb:452
1264
+ def post_cmd=(_arg0); end
1265
+
1266
+ # An array of commands prepended to compiled code
1267
+ #
1268
+ # pkg:gem/erb#lib/erb/compiler.rb:449
1269
+ def pre_cmd; end
1270
+
1271
+ # An array of commands prepended to compiled code
1272
+ #
1273
+ # pkg:gem/erb#lib/erb/compiler.rb:449
1274
+ def pre_cmd=(_arg0); end
1275
+
1276
+ # pkg:gem/erb#lib/erb/compiler.rb:398
1277
+ def prepare_trim_mode(mode); end
1278
+
1279
+ # The command to handle text that ends with a newline
1280
+ #
1281
+ # pkg:gem/erb#lib/erb/compiler.rb:443
1282
+ def put_cmd; end
1283
+
1284
+ # The command to handle text that ends with a newline
1285
+ #
1286
+ # pkg:gem/erb#lib/erb/compiler.rb:443
1287
+ def put_cmd=(_arg0); end
1288
+
1289
+ # pkg:gem/erb#lib/erb/compiler.rb:440
1290
+ def trim_mode; end
1291
+
1292
+ private
1293
+
1294
+ # A buffered text in #compile
1295
+ #
1296
+ # pkg:gem/erb#lib/erb/compiler.rb:457
1297
+ def content; end
1298
+
1299
+ # A buffered text in #compile
1300
+ #
1301
+ # pkg:gem/erb#lib/erb/compiler.rb:457
1302
+ def content=(_arg0); end
1303
+
1304
+ # pkg:gem/erb#lib/erb/compiler.rb:459
1305
+ def detect_magic_comment(s, enc = T.unsafe(nil)); end
1306
+
1307
+ # pkg:gem/erb#lib/erb/compiler.rb:484
1308
+ def warn_invalid_trim_mode(mode, uplevel:); end
1309
+ end
1310
+
1311
+ # pkg:gem/erb#lib/erb/compiler.rb:278
1312
+ class ERB::Compiler::Buffer
1313
+ # pkg:gem/erb#lib/erb/compiler.rb:279
1314
+ def initialize(compiler, enc = T.unsafe(nil), frozen = T.unsafe(nil)); end
1315
+
1316
+ # pkg:gem/erb#lib/erb/compiler.rb:301
1317
+ def close; end
1318
+
1319
+ # pkg:gem/erb#lib/erb/compiler.rb:295
1320
+ def cr; end
1321
+
1322
+ # pkg:gem/erb#lib/erb/compiler.rb:291
1323
+ def push(cmd); end
1324
+
1325
+ # pkg:gem/erb#lib/erb/compiler.rb:289
1326
+ def script; end
1327
+ end
1328
+
1329
+ # pkg:gem/erb#lib/erb/compiler.rb:254
1330
+ class ERB::Compiler::ExplicitScanner < ::ERB::Compiler::Scanner
1331
+ # pkg:gem/erb#lib/erb/compiler.rb:255
1332
+ def scan; end
1333
+ end
1334
+
1335
+ # pkg:gem/erb#lib/erb/compiler.rb:74
1336
+ class ERB::Compiler::PercentLine
1337
+ # pkg:gem/erb#lib/erb/compiler.rb:75
1338
+ def initialize(str); end
1339
+
1340
+ # pkg:gem/erb#lib/erb/compiler.rb:79
1341
+ def to_s; end
1342
+
1343
+ # pkg:gem/erb#lib/erb/compiler.rb:78
1344
+ def value; end
1345
+ end
1346
+
1347
+ # pkg:gem/erb#lib/erb/compiler.rb:82
1348
+ class ERB::Compiler::Scanner
1349
+ # pkg:gem/erb#lib/erb/compiler.rb:108
1350
+ def initialize(src, trim_mode, percent); end
1351
+
1352
+ # pkg:gem/erb#lib/erb/compiler.rb:115
1353
+ def etags; end
1354
+
1355
+ # pkg:gem/erb#lib/erb/compiler.rb:117
1356
+ def scan; end
1357
+
1358
+ # pkg:gem/erb#lib/erb/compiler.rb:114
1359
+ def stag; end
1360
+
1361
+ # pkg:gem/erb#lib/erb/compiler.rb:114
1362
+ def stag=(_arg0); end
1363
+
1364
+ # pkg:gem/erb#lib/erb/compiler.rb:115
1365
+ def stags; end
1366
+
1367
+ class << self
1368
+ # pkg:gem/erb#lib/erb/compiler.rb:97
1369
+ def default_scanner=(klass); end
1370
+
1371
+ # pkg:gem/erb#lib/erb/compiler.rb:101
1372
+ def make_scanner(src, trim_mode, percent); end
1373
+
1374
+ # pkg:gem/erb#lib/erb/compiler.rb:94
1375
+ def regist_scanner(klass, trim_mode, percent); end
1376
+
1377
+ # pkg:gem/erb#lib/erb/compiler.rb:86
1378
+ def register_scanner(klass, trim_mode, percent); end
1379
+ end
1380
+ end
1381
+
1382
+ # pkg:gem/erb#lib/erb/compiler.rb:107
1383
+ ERB::Compiler::Scanner::DEFAULT_ETAGS = T.let(T.unsafe(nil), Array)
1384
+
1385
+ # pkg:gem/erb#lib/erb/compiler.rb:106
1386
+ ERB::Compiler::Scanner::DEFAULT_STAGS = T.let(T.unsafe(nil), Array)
1387
+
1388
+ # pkg:gem/erb#lib/erb/compiler.rb:240
1389
+ class ERB::Compiler::SimpleScanner < ::ERB::Compiler::Scanner
1390
+ # pkg:gem/erb#lib/erb/compiler.rb:241
1391
+ def scan; end
1392
+ end
1393
+
1394
+ # pkg:gem/erb#lib/erb/compiler.rb:120
1395
+ class ERB::Compiler::TrimScanner < ::ERB::Compiler::Scanner
1396
+ # pkg:gem/erb#lib/erb/compiler.rb:121
1397
+ def initialize(src, trim_mode, percent); end
1398
+
1399
+ # pkg:gem/erb#lib/erb/compiler.rb:210
1400
+ def explicit_trim_line(line); end
1401
+
1402
+ # pkg:gem/erb#lib/erb/compiler.rb:229
1403
+ def is_erb_stag?(s); end
1404
+
1405
+ # pkg:gem/erb#lib/erb/compiler.rb:152
1406
+ def percent_line(line, &block); end
1407
+
1408
+ # pkg:gem/erb#lib/erb/compiler.rb:140
1409
+ def scan(&block); end
1410
+
1411
+ # pkg:gem/erb#lib/erb/compiler.rb:165
1412
+ def scan_line(line); end
1413
+
1414
+ # pkg:gem/erb#lib/erb/compiler.rb:174
1415
+ def trim_line1(line); end
1416
+
1417
+ # pkg:gem/erb#lib/erb/compiler.rb:188
1418
+ def trim_line2(line); end
1419
+ end
1420
+
1421
+ # :stopdoc:
1422
+ #
1423
+ # pkg:gem/erb#lib/erb/compiler.rb:476
1424
+ ERB::Compiler::WARNING_UPLEVEL = T.let(T.unsafe(nil), Integer)
1425
+
1426
+ # ERB::DefMethod
1427
+ #
1428
+ # Utility module to define eRuby script as instance method.
1429
+ #
1430
+ # === Example
1431
+ #
1432
+ # example.rhtml:
1433
+ # <% for item in @items %>
1434
+ # <b><%= item %></b>
1435
+ # <% end %>
1436
+ #
1437
+ # example.rb:
1438
+ # require 'erb'
1439
+ # class MyClass
1440
+ # extend ERB::DefMethod
1441
+ # def_erb_method('render()', 'example.rhtml')
1442
+ # def initialize(items)
1443
+ # @items = items
1444
+ # end
1445
+ # end
1446
+ # print MyClass.new([10,20,30]).render()
1447
+ #
1448
+ # result:
1449
+ #
1450
+ # <b>10</b>
1451
+ #
1452
+ # <b>20</b>
1453
+ #
1454
+ # <b>30</b>
1455
+ #
1456
+ # pkg:gem/erb#lib/erb/def_method.rb:33
1457
+ module ERB::DefMethod
1458
+ private
1459
+
1460
+ # define _methodname_ as instance method of current module, using ERB
1461
+ # object or eRuby file
1462
+ #
1463
+ # pkg:gem/erb#lib/erb/def_method.rb:36
1464
+ def def_erb_method(methodname, erb_or_fname); end
1465
+
1466
+ class << self
1467
+ # define _methodname_ as instance method of current module, using ERB
1468
+ # object or eRuby file
1469
+ #
1470
+ # pkg:gem/erb#lib/erb/def_method.rb:46
1471
+ def def_erb_method(methodname, erb_or_fname); end
1472
+ end
1473
+ end
1474
+
1475
+ # ERB::Util
1476
+ #
1477
+ # A utility module for conversion routines, often handy in HTML generation.
1478
+ #
1479
+ # pkg:gem/erb#lib/erb/util.rb:33
1480
+ module ERB::Util
1481
+ include ::ERB::Escape
1482
+
1483
+ private
1484
+
1485
+ # pkg:gem/erb#lib/erb/util.rb:48
1486
+ def h(_arg0); end
1487
+
1488
+ # pkg:gem/erb#lib/erb/util.rb:74
1489
+ def u(s); end
1490
+
1491
+ # A utility method for encoding the String _s_ as a URL.
1492
+ #
1493
+ # require "erb"
1494
+ # include ERB::Util
1495
+ #
1496
+ # puts url_encode("Programming Ruby: The Pragmatic Programmer's Guide")
1497
+ #
1498
+ # _Generates_
1499
+ #
1500
+ # Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide
1501
+ #
1502
+ # cgi.gem <= v0.3.2
1503
+ #
1504
+ # pkg:gem/erb#lib/erb/util.rb:64
1505
+ def url_encode(s); end
1506
+
1507
+ class << self
1508
+ # pkg:gem/erb#lib/erb/util.rb:49
1509
+ def h(_arg0); end
1510
+
1511
+ # pkg:gem/erb#lib/erb/util.rb:47
1512
+ def html_escape(_arg0); end
1513
+
1514
+ # pkg:gem/erb#lib/erb/util.rb:75
1515
+ def u(s); end
1516
+
1517
+ # A utility method for encoding the String _s_ as a URL.
1518
+ #
1519
+ # require "erb"
1520
+ # include ERB::Util
1521
+ #
1522
+ # puts url_encode("Programming Ruby: The Pragmatic Programmer's Guide")
1523
+ #
1524
+ # _Generates_
1525
+ #
1526
+ # Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide
1527
+ #
1528
+ # cgi.gem <= v0.3.2
1529
+ #
1530
+ # pkg:gem/erb#lib/erb/util.rb:76
1531
+ def url_encode(s); end
1532
+ end
1533
+ end
1534
+
1535
+ # The string \ERB version.
1536
+ #
1537
+ # pkg:gem/erb#lib/erb/version.rb:4
1538
+ ERB::VERSION = T.let(T.unsafe(nil), String)