<%= @desc %>
-# -#-# <% if @cost < 10 %> -# Only <%= @cost %>!!! -# <% else %> -# Call for a price, today! -# <% end %> -#
-# -# -# -# }.gsub(/^ /, '') -# -# rhtml = ERB.new(template) -# -# # Set up template data. -# toy = Product.new( "TZ-1002", -# "Rubysapien", -# "Geek's Best Friend! Responds to Ruby commands...", -# 999.95 ) -# toy.add_feature("Listens for verbal commands in the Ruby language!") -# toy.add_feature("Ignores Perl, Java, and all C variants.") -# toy.add_feature("Karate-Chop Action!!!") -# toy.add_feature("Matz signature on left leg.") -# toy.add_feature("Gem studded eyes... Rubies, of course!") -# -# # Produce result. -# rhtml.run(toy.get_binding) -# -# Generates (some blank lines removed): -# -# -#Geek's Best Friend! Responds to Ruby commands...
-# -#-# Call for a price, today! -#
-# -# -# -# -# -# == Notes -# -# There are a variety of templating solutions available in various Ruby projects. -# For example, RDoc, distributed with Ruby, uses its own template engine, which -# can be reused elsewhere. -# -# Other popular engines could be found in the corresponding -# {Category}[https://www.ruby-toolbox.com/categories/template_engines] of -# The Ruby Toolbox. -# -# source://erb//lib/erb/version.rb#2 -class ERB - # Constructs a new ERB object with the template specified in _str_. - # - # An ERB object works by building a chunk of Ruby code that will output - # the completed template when run. - # - # If _trim_mode_ is passed a String containing one or more of the following - # modifiers, ERB will adjust its code generation as listed: - # - # % enables Ruby code processing for lines beginning with % - # <> omit newline for lines starting with <% and ending in %> - # > omit newline for lines ending in %> - # - omit blank lines ending in -%> - # - # _eoutvar_ can be used to set the name of the variable ERB will build up - # its output in. This is useful when you need to run multiple ERB - # templates through the same binding and/or when you want to control where - # output ends up. Pass the name of the variable to be used inside a String. - # - # === Example - # - # require "erb" - # - # # build data class - # class Listings - # PRODUCT = { :name => "Chicken Fried Steak", - # :desc => "A well messaged pattie, breaded and fried.", - # :cost => 9.95 } - # - # attr_reader :product, :price - # - # def initialize( product = "", price = "" ) - # @product = product - # @price = price - # end - # - # def build - # b = binding - # # create and run templates, filling member data variables - # ERB.new(<<~'END_PRODUCT', trim_mode: "", eoutvar: "@product").result b - # <%= PRODUCT[:name] %> - # <%= PRODUCT[:desc] %> - # END_PRODUCT - # ERB.new(<<~'END_PRICE', trim_mode: "", eoutvar: "@price").result b - # <%= PRODUCT[:name] %> -- <%= PRODUCT[:cost] %> - # <%= PRODUCT[:desc] %> - # END_PRICE - # end - # end - # - # # setup template data - # listings = Listings.new - # listings.build - # - # puts listings.product + "\n" + listings.price - # - # _Generates_ - # - # Chicken Fried Steak - # A well massaged pattie, breaded and fried. - # - # Chicken Fried Steak -- 9.95 - # A well massaged pattie, breaded and fried. - # - # @return [ERB] a new instance of ERB - # - # source://erb//lib/erb.rb#334 - def initialize(str, safe_level = T.unsafe(nil), legacy_trim_mode = T.unsafe(nil), legacy_eoutvar = T.unsafe(nil), trim_mode: T.unsafe(nil), eoutvar: T.unsafe(nil)); end - - # Define unnamed class which has _methodname_ as instance method, and return it. - # - # example: - # class MyClass_ - # def initialize(arg1, arg2) - # @arg1 = arg1; @arg2 = arg2 - # end - # end - # filename = 'example.rhtml' # @arg1 and @arg2 are used in example.rhtml - # erb = ERB.new(File.read(filename)) - # erb.filename = filename - # MyClass = erb.def_class(MyClass_, 'render()') - # print MyClass.new('foo', 123).render() - # - # source://erb//lib/erb.rb#499 - def def_class(superklass = T.unsafe(nil), methodname = T.unsafe(nil)); end - - # Define _methodname_ as instance method of _mod_ from compiled Ruby source. - # - # example: - # filename = 'example.rhtml' # 'arg1' and 'arg2' are used in example.rhtml - # erb = ERB.new(File.read(filename)) - # erb.def_method(MyClass, 'render(arg1, arg2)', filename) - # print MyClass.new.render('foo', 123) - # - # source://erb//lib/erb.rb#463 - def def_method(mod, methodname, fname = T.unsafe(nil)); end - - # Create unnamed module, define _methodname_ as instance method of it, and return it. - # - # example: - # filename = 'example.rhtml' # 'arg1' and 'arg2' are used in example.rhtml - # erb = ERB.new(File.read(filename)) - # erb.filename = filename - # MyModule = erb.def_module('render(arg1, arg2)') - # class MyClass - # include MyModule - # end - # - # source://erb//lib/erb.rb#480 - def def_module(methodname = T.unsafe(nil)); end - - # The encoding to eval - # - # source://erb//lib/erb.rb#369 - def encoding; end - - # The optional _filename_ argument passed to Kernel#eval when the ERB code - # is run - # - # source://erb//lib/erb.rb#373 - def filename; end - - # The optional _filename_ argument passed to Kernel#eval when the ERB code - # is run - # - # source://erb//lib/erb.rb#373 - def filename=(_arg0); end - - # The optional _lineno_ argument passed to Kernel#eval when the ERB code - # is run - # - # source://erb//lib/erb.rb#377 - def lineno; end - - # The optional _lineno_ argument passed to Kernel#eval when the ERB code - # is run - # - # source://erb//lib/erb.rb#377 - def lineno=(_arg0); end - - # Sets optional filename and line number that will be used in ERB code - # evaluation and error reporting. See also #filename= and #lineno= - # - # erb = ERB.new('<%= some_x %>') - # erb.render - # # undefined local variable or method `some_x' - # # from (erb):1 - # - # erb.location = ['file.erb', 3] - # # All subsequent error reporting would use new location - # erb.render - # # undefined local variable or method `some_x' - # # from file.erb:4 - # - # source://erb//lib/erb.rb#394 - def location=(_arg0); end - - # Creates a new compiler for ERB. See ERB::Compiler.new for details - # - # source://erb//lib/erb.rb#361 - def make_compiler(trim_mode); end - - # Executes the generated ERB code to produce a completed template, returning - # the results of that code. - # - # _b_ accepts a Binding object which is used to set the context of - # code evaluation. - # - # source://erb//lib/erb.rb#423 - def result(b = T.unsafe(nil)); end - - # Render a template on a new toplevel binding with local variables specified - # by a Hash object. - # - # source://erb//lib/erb.rb#432 - def result_with_hash(hash); end - - # Generate results and print them. (see ERB#result) - # - # source://erb//lib/erb.rb#412 - def run(b = T.unsafe(nil)); end - - # Can be used to set _eoutvar_ as described in ERB::new. It's probably - # easier to just use the constructor though, since calling this method - # requires the setup of an ERB _compiler_ object. - # - # source://erb//lib/erb.rb#404 - def set_eoutvar(compiler, eoutvar = T.unsafe(nil)); end - - # The Ruby code generated by ERB - # - # source://erb//lib/erb.rb#366 - def src; end - - private - - # Returns a new binding each time *near* TOPLEVEL_BINDING for runs that do - # not specify a binding. - # - # source://erb//lib/erb.rb#444 - def new_toplevel(vars = T.unsafe(nil)); end - - class << self - # Returns revision information for the erb.rb module. - # - # source://erb//lib/erb.rb#266 - def version; end - end -end - -# -- -# ERB::Compiler -# -# Compiles ERB templates into Ruby code; the compiled code produces the -# template result when evaluated. ERB::Compiler provides hooks to define how -# generated output is handled. -# -# Internally ERB does something like this to generate the code returned by -# ERB#src: -# -# compiler = ERB::Compiler.new('<>') -# compiler.pre_cmd = ["_erbout=+''"] -# compiler.put_cmd = "_erbout.<<" -# compiler.insert_cmd = "_erbout.<<" -# compiler.post_cmd = ["_erbout"] -# -# code, enc = compiler.compile("Got <%= obj %>!\n") -# puts code -# -# Generates: -# -# #coding:UTF-8 -# _erbout=+''; _erbout.<< "Got ".freeze; _erbout.<<(( obj ).to_s); _erbout.<< "!\n".freeze; _erbout -# -# By default the output is sent to the print method. For example: -# -# compiler = ERB::Compiler.new('<>') -# code, enc = compiler.compile("Got <%= obj %>!\n") -# puts code -# -# Generates: -# -# #coding:UTF-8 -# print "Got ".freeze; print(( obj ).to_s); print "!\n".freeze -# -# == Evaluation -# -# The compiled code can be used in any context where the names in the code -# correctly resolve. Using the last example, each of these print 'Got It!' -# -# Evaluate using a variable: -# -# obj = 'It' -# eval code -# -# Evaluate using an input: -# -# mod = Module.new -# mod.module_eval %{ -# def get(obj) -# #{code} -# end -# } -# extend mod -# get('It') -# -# Evaluate using an accessor: -# -# klass = Class.new Object -# klass.class_eval %{ -# attr_accessor :obj -# def initialize(obj) -# @obj = obj -# end -# def get_it -# #{code} -# end -# } -# klass.new('It').get_it -# -# Good! See also ERB#def_method, ERB#def_module, and ERB#def_class. -# -# source://erb//lib/erb/compiler.rb#73 -class ERB::Compiler - # Construct a new compiler using the trim_mode. See ERB::new for available - # trim modes. - # - # @return [Compiler] a new instance of Compiler - # - # source://erb//lib/erb/compiler.rb#433 - def initialize(trim_mode); end - - # source://erb//lib/erb/compiler.rb#315 - def add_insert_cmd(out, content); end - - # source://erb//lib/erb/compiler.rb#311 - def add_put_cmd(out, content); end - - # Compiles an ERB template into Ruby code. Returns an array of the code - # and encoding like ["code", Encoding]. - # - # @raise [ArgumentError] - # - # source://erb//lib/erb/compiler.rb#321 - def compile(s); end - - # source://erb//lib/erb/compiler.rb#381 - def compile_content(stag, out); end - - # source://erb//lib/erb/compiler.rb#368 - def compile_etag(etag, out, scanner); end - - # source://erb//lib/erb/compiler.rb#344 - def compile_stag(stag, out, scanner); end - - # The command to handle text that is inserted prior to a newline - # - # source://erb//lib/erb/compiler.rb#446 - def insert_cmd; end - - # The command to handle text that is inserted prior to a newline - # - # source://erb//lib/erb/compiler.rb#446 - def insert_cmd=(_arg0); end - - # source://erb//lib/erb/compiler.rb#427 - def make_scanner(src); end - - # Returns the value of attribute percent. - # - # source://erb//lib/erb/compiler.rb#440 - def percent; end - - # An array of commands appended to compiled code - # - # source://erb//lib/erb/compiler.rb#452 - def post_cmd; end - - # An array of commands appended to compiled code - # - # source://erb//lib/erb/compiler.rb#452 - def post_cmd=(_arg0); end - - # An array of commands prepended to compiled code - # - # source://erb//lib/erb/compiler.rb#449 - def pre_cmd; end - - # An array of commands prepended to compiled code - # - # source://erb//lib/erb/compiler.rb#449 - def pre_cmd=(_arg0); end - - # source://erb//lib/erb/compiler.rb#398 - def prepare_trim_mode(mode); end - - # The command to handle text that ends with a newline - # - # source://erb//lib/erb/compiler.rb#443 - def put_cmd; end - - # The command to handle text that ends with a newline - # - # source://erb//lib/erb/compiler.rb#443 - def put_cmd=(_arg0); end - - # Returns the value of attribute trim_mode. - # - # source://erb//lib/erb/compiler.rb#440 - def trim_mode; end - - private - - # A buffered text in #compile - # - # source://erb//lib/erb/compiler.rb#457 - def content; end - - # A buffered text in #compile - # - # source://erb//lib/erb/compiler.rb#457 - def content=(_arg0); end - - # source://erb//lib/erb/compiler.rb#459 - def detect_magic_comment(s, enc = T.unsafe(nil)); end - - # :startdoc: - # - # source://erb//lib/erb/compiler.rb#485 - def warn_invalid_trim_mode(mode, uplevel:); end -end - -# source://erb//lib/erb/compiler.rb#278 -class ERB::Compiler::Buffer - # @return [Buffer] a new instance of Buffer - # - # source://erb//lib/erb/compiler.rb#279 - def initialize(compiler, enc = T.unsafe(nil), frozen = T.unsafe(nil)); end - - # source://erb//lib/erb/compiler.rb#301 - def close; end - - # source://erb//lib/erb/compiler.rb#295 - def cr; end - - # source://erb//lib/erb/compiler.rb#291 - def push(cmd); end - - # Returns the value of attribute script. - # - # source://erb//lib/erb/compiler.rb#289 - def script; end -end - -# source://erb//lib/erb/compiler.rb#254 -class ERB::Compiler::ExplicitScanner < ::ERB::Compiler::Scanner - # source://erb//lib/erb/compiler.rb#255 - def scan; end -end - -# source://erb//lib/erb/compiler.rb#74 -class ERB::Compiler::PercentLine - # @return [PercentLine] a new instance of PercentLine - # - # source://erb//lib/erb/compiler.rb#75 - def initialize(str); end - - # Returns the value of attribute value. - # - # source://erb//lib/erb/compiler.rb#79 - def to_s; end - - # Returns the value of attribute value. - # - # source://erb//lib/erb/compiler.rb#78 - def value; end -end - -# source://erb//lib/erb/compiler.rb#82 -class ERB::Compiler::Scanner - # @return [Scanner] a new instance of Scanner - # - # source://erb//lib/erb/compiler.rb#108 - def initialize(src, trim_mode, percent); end - - # Returns the value of attribute etags. - # - # source://erb//lib/erb/compiler.rb#115 - def etags; end - - # source://erb//lib/erb/compiler.rb#117 - def scan; end - - # Returns the value of attribute stag. - # - # source://erb//lib/erb/compiler.rb#114 - def stag; end - - # Sets the attribute stag - # - # @param value the value to set the attribute stag to. - # - # source://erb//lib/erb/compiler.rb#114 - def stag=(_arg0); end - - # Returns the value of attribute stags. - # - # source://erb//lib/erb/compiler.rb#115 - def stags; end - - class << self - # source://erb//lib/erb/compiler.rb#97 - def default_scanner=(klass); end - - # source://erb//lib/erb/compiler.rb#101 - def make_scanner(src, trim_mode, percent); end - - # source://erb//lib/erb/compiler.rb#94 - def regist_scanner(klass, trim_mode, percent); end - - # source://erb//lib/erb/compiler.rb#86 - def register_scanner(klass, trim_mode, percent); end - end -end - -# source://erb//lib/erb/compiler.rb#107 -ERB::Compiler::Scanner::DEFAULT_ETAGS = T.let(T.unsafe(nil), Array) - -# source://erb//lib/erb/compiler.rb#106 -ERB::Compiler::Scanner::DEFAULT_STAGS = T.let(T.unsafe(nil), Array) - -# source://erb//lib/erb/compiler.rb#240 -class ERB::Compiler::SimpleScanner < ::ERB::Compiler::Scanner - # source://erb//lib/erb/compiler.rb#241 - def scan; end -end - -# source://erb//lib/erb/compiler.rb#120 -class ERB::Compiler::TrimScanner < ::ERB::Compiler::Scanner - # @return [TrimScanner] a new instance of TrimScanner - # - # source://erb//lib/erb/compiler.rb#121 - def initialize(src, trim_mode, percent); end - - # source://erb//lib/erb/compiler.rb#210 - def explicit_trim_line(line); end - - # @return [Boolean] - # - # source://erb//lib/erb/compiler.rb#229 - def is_erb_stag?(s); end - - # source://erb//lib/erb/compiler.rb#152 - def percent_line(line, &block); end - - # source://erb//lib/erb/compiler.rb#140 - def scan(&block); end - - # source://erb//lib/erb/compiler.rb#165 - def scan_line(line); end - - # source://erb//lib/erb/compiler.rb#174 - def trim_line1(line); end - - # source://erb//lib/erb/compiler.rb#188 - def trim_line2(line); end -end - -# :stopdoc: -# -# source://erb//lib/erb/compiler.rb#476 -ERB::Compiler::WARNING_UPLEVEL = T.let(T.unsafe(nil), Integer) - -# ERB::DefMethod -# -# Utility module to define eRuby script as instance method. -# -# === Example -# -# example.rhtml: -# <% for item in @items %> -# <%= item %> -# <% end %> -# -# example.rb: -# require 'erb' -# class MyClass -# extend ERB::DefMethod -# def_erb_method('render()', 'example.rhtml') -# def initialize(items) -# @items = items -# end -# end -# print MyClass.new([10,20,30]).render() -# -# result: -# -# 10 -# -# 20 -# -# 30 -# -# source://erb//lib/erb/def_method.rb#33 -module ERB::DefMethod - private - - # define _methodname_ as instance method of current module, using ERB - # object or eRuby file - # - # source://erb//lib/erb/def_method.rb#36 - def def_erb_method(methodname, erb_or_fname); end - - class << self - # define _methodname_ as instance method of current module, using ERB - # object or eRuby file - # - # source://erb//lib/erb/def_method.rb#46 - def def_erb_method(methodname, erb_or_fname); end - end -end - -module ERB::Escape; end - -# source://erb//lib/erb.rb#355 -ERB::NOT_GIVEN = T.let(T.unsafe(nil), Object) - -# ERB::Util -# -# A utility module for conversion routines, often handy in HTML generation. -# -# source://erb//lib/erb/util.rb#32 -module ERB::Util - include ::ERB::Escape - - private - - # source://erb//lib/erb/util.rb#47 - def h(_arg0); end - - # cgi.gem <= v0.3.2 - # - # source://erb//lib/erb/util.rb#73 - def u(s); end - - # cgi.gem <= v0.3.2 - # - # source://erb//lib/erb/util.rb#63 - def url_encode(s); end - - class << self - # source://erb//lib/erb/util.rb#48 - def h(_arg0); end - - # source://erb//lib/erb/util.rb#46 - def html_escape(_arg0); end - - # cgi.gem <= v0.3.2 - # - # source://erb//lib/erb/util.rb#74 - def u(s); end - - # cgi.gem <= v0.3.2 - # - # source://erb//lib/erb/util.rb#75 - def url_encode(s); end - end -end - -# source://erb//lib/erb/version.rb#3 -ERB::VERSION = T.let(T.unsafe(nil), String) diff --git a/sorbet/rbi/gems/erb@6.0.1.rbi b/sorbet/rbi/gems/erb@6.0.1.rbi new file mode 100644 index 0000000000..cfe5487e40 --- /dev/null +++ b/sorbet/rbi/gems/erb@6.0.1.rbi @@ -0,0 +1,816 @@ +# typed: false + +# DO NOT EDIT MANUALLY +# This is an autogenerated file for types exported from the `erb` gem. +# Please instead update this file by running `bin/tapioca gem erb`. + + +# source://erb//lib/erb/version.rb#2 +class ERB + # :markup: markdown + # + # :call-seq: + # ERB.new(template, trim_mode: nil, eoutvar: '_erbout') + # + # Returns a new \ERB object containing the given string +template+. + # + # For details about `template`, its embedded tags, and generated results, see ERB. + # + # **Keyword Argument `trim_mode`** + # + # You can use keyword argument `trim_mode: '%'` + # to enable the [shorthand format][shorthand format] for execution tags. + # + # This value allows [blank line control][blank line control]: + # + # - `'-'`: Omit each blank line ending with `'%>'`. + # + # Other values allow [newline control][newline control]: + # + # - `'>'`: Omit newline for each line ending with `'%>'`. + # - `'<>'`: Omit newline for each line starting with `'<%'` and ending with `'%>'`. + # + # You can also [combine trim modes][combine trim modes]. + # + # **Keyword Argument `eoutvar`** + # + # The string value of keyword argument `eoutvar` specifies the name of the variable + # that method #result uses to construct its result string; + # see #src. + # + # This is useful when you need to run multiple \ERB templates through the same binding + # and/or when you want to control where output ends up. + # + # It's good practice to choose a variable name that begins with an underscore: `'_'`. + # + # [blank line control]: rdoc-ref:ERB@Suppressing+Unwanted+Blank+Lines + # [combine trim modes]: rdoc-ref:ERB@Combining+Trim+Modes + # [newline control]: rdoc-ref:ERB@Suppressing+Unwanted+Newlines + # [shorthand format]: rdoc-ref:ERB@Shorthand+Format+for+Execution+Tags + # + # @return [ERB] a new instance of ERB + # + # source://erb//lib/erb.rb#832 + def initialize(str, trim_mode: T.unsafe(nil), eoutvar: T.unsafe(nil)); end + + # :markup: markdown + # + # :call-seq: + # def_class(super_class = Object, method_name = 'result') -> new_class + # + # Returns a new nameless class whose superclass is `super_class`, + # and which has instance method `method_name`. + # + # Create a template from HTML that has embedded expression tags that use `@arg1` and `@arg2`: + # + # ``` + # html = < + # + #<%= @arg1 %>
+ #<%= @arg2 %>
+ # + #