Returns a printable version of ec
ec = Encoding::Converter.new("iso-8859-1", "utf-8") puts ec.inspect #=> #<Encoding::Converter: ISO-8859-1 to UTF-8>
Finishes the converter. It returns the last part of the converted string.
ec = Encoding::Converter.new("utf-8", "iso-2022-jp") p ec.convert("\u3042") #=> "\e$B$\"" p ec.finish #=> "\e(B"
Returns maximum backtrace length set by --backtrace-limit
command-line option. The defalt is -1
which means unlimited backtraces. If the value is zero or positive, the error backtraces, produced by Exception#full_message
, are abbreviated and the extra lines are replaced by ... 3 levels...
$ ruby -r net/http -e "p Thread::Backtrace.limit; Net::HTTP.get(URI('http://wrong.address'))" - 1 .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': Failed to open TCP connection to wrong.address:80 (getaddrinfo: Name or service not known) (SocketError) from .../lib/ruby/3.1.0/socket.rb:227:in `foreach' from .../lib/ruby/3.1.0/socket.rb:632:in `tcp' from .../lib/ruby/3.1.0/net/http.rb:998:in `connect' from .../lib/ruby/3.1.0/net/http.rb:976:in `do_start' from .../lib/ruby/3.1.0/net/http.rb:965:in `start' from .../lib/ruby/3.1.0/net/http.rb:627:in `start' from .../lib/ruby/3.1.0/net/http.rb:503:in `get_response' from .../lib/ruby/3.1.0/net/http.rb:474:in `get' .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': getaddrinfo: Name or service not known (SocketError) from .../lib/ruby/3.1.0/socket.rb:227:in `foreach' from .../lib/ruby/3.1.0/socket.rb:632:in `tcp' from .../lib/ruby/3.1.0/net/http.rb:998:in `connect' from .../lib/ruby/3.1.0/net/http.rb:976:in `do_start' from .../lib/ruby/3.1.0/net/http.rb:965:in `start' from .../lib/ruby/3.1.0/net/http.rb:627:in `start' from .../lib/ruby/3.1.0/net/http.rb:503:in `get_response' from .../lib/ruby/3.1.0/net/http.rb:474:in `get' from -e:1:in `<main>' $ ruby --backtrace-limit 2 -r net/http -e "p Thread::Backtrace.limit; Net::HTTP.get(URI('http://wrong.address'))" 2 .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': Failed to open TCP connection to wrong.address:80 (getaddrinfo: Name or service not known) (SocketError) from .../lib/ruby/3.1.0/socket.rb:227:in `foreach' from .../lib/ruby/3.1.0/socket.rb:632:in `tcp' ... 7 levels... .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': getaddrinfo: Name or service not known (SocketError) from .../lib/ruby/3.1.0/socket.rb:227:in `foreach' from .../lib/ruby/3.1.0/socket.rb:632:in `tcp' ... 7 levels... $ ruby --backtrace-limit 0 -r net/http -e "p Thread::Backtrace.limit; Net::HTTP.get(URI('http://wrong.address'))" 0 .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': Failed to open TCP connection to wrong.address:80 (getaddrinfo: Name or service not known) (SocketError) ... 9 levels... .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': getaddrinfo: Name or service not known (SocketError) ... 9 levels...
Finishes the digest and returns the resulting hash value.
This method is overridden by each implementation subclass and often made private, because some of those subclasses may leave internal data uninitialized. Do not call this method from outside. Use digest!()
instead, which ensures that internal data be reset for security reasons.
Creates a printable version of the digest object.
Creates a global method from the given C signature
using the given opts
as bind parameters with the given block.
Reads a line from the stream which is separated by eol.
Raises EOFError
if at end of file.
Formats and writes to the stream converting parameters under control of the format string.
See Kernel#sprintf
for format string details.
Generate a submit button Input element, as a String
.
value
is the text to display on the button. name
is the name of the input.
Alternatively, the attributes can be specified as a hash.
submit # <INPUT TYPE="submit"> submit("ok") # <INPUT TYPE="submit" VALUE="ok"> submit("ok", "button1") # <INPUT TYPE="submit" VALUE="ok" NAME="button1"> submit("VALUE" => "ok", "NAME" => "button1", "ID" => "foo") # <INPUT TYPE="submit" VALUE="ok" NAME="button1" ID="foo">
Check if gem name
version version
is installed.
A Zlib::Inflate#inflate
wrapper
This method is deprecated and should not be used. This is a no-op.
Returns whether this dependency, which has no possible matching specifications, can safely be ignored.
@param [Object] dependency @return [Boolean] whether this dependency can safely be skipped.
Replaces the content of self
with the content of other_array
; returns self
:
a = [:foo, 'bar', 2] a.replace(['foo', :bar, 3]) # => ["foo", :bar, 3]
Iterates over array indexes.
When a block given, passes each successive array index to the block; returns self
:
a = [:foo, 'bar', 2] a.each_index {|index| puts "#{index} #{a[index]}" }
Output:
0 foo 1 bar 2 2
Allows the array to be modified during iteration:
a = [:foo, 'bar', 2] a.each_index {|index| puts index; a.clear if index > 0 }
Output:
0 1
When no block given, returns a new Enumerator:
a = [:foo, 'bar', 2] e = a.each_index e # => #<Enumerator: [:foo, "bar", 2]:each_index> a1 = e.each {|index| puts "#{index} #{a[index]}"}
Output:
0 foo 1 bar 2 2
Related: each
, reverse_each
.