Add the –version option to the option parser.
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]
Replaces the contents of self
with the contents of other_string
:
s = 'foo' # => "foo" s.replace('bar') # => "bar"
Returns whether self
starts with any of the given string_or_regexp
.
Matches patterns against the beginning of self
. For each given string_or_regexp
, the pattern is:
string_or_regexp
itself, if it is a Regexp
.
Regexp.quote(string_or_regexp)
, if string_or_regexp
is a string.
Returns true
if any pattern matches the beginning, false
otherwise:
'hello'.start_with?('hell') # => true 'hello'.start_with?(/H/i) # => true 'hello'.start_with?('heaven', 'hell') # => true 'hello'.start_with?('heaven', 'paradise') # => false 'тест'.start_with?('т') # => true 'こんにちは'.start_with?('こ') # => true
Related: String#end_with?
.
Returns whether ASCII-compatible or not.
Encoding::UTF_8.ascii_compatible? #=> true Encoding::UTF_16BE.ascii_compatible? #=> false
Waits until IO
is priority and returns a truthy value or a falsy value when times out. Priority data is sent and received using the Socket::MSG_OOB flag and is typically limited to streams.
You must require ‘io/wait’ to use this method.
Returns true
if matching against re
can be done in linear time to the input string.
Regexp.linear_time?(/re/) # => true
Note that this is a property of the ruby interpreter, not of the argument regular expression. Identical regexp can or cannot run in linear time depending on your ruby binary. Neither forward nor backward compatibility is guaranteed about the return value of this method. Our current algorithm is (*1) but this is subject to change in the future. Alternative implementations can also behave differently. They might always return false for everything.
Dup internal hash.
Equivalent to self.to_s.start_with?
; see String#start_with?
.
Returns a shallow copy of self
; the [stored string] in the copy is the same string as in self
.
Replaces the entire contents of self
with the contents of other_hash
; returns self
:
h = {foo: 0, bar: 1, baz: 2} h.replace({bat: 3, bam: 4}) # => {:bat=>3, :bam=>4}
The version of the Marshal
format for your Ruby.
How String
Gem paths should be split. Overridable for esoteric platforms.
Get a single optional argument from the command line. If more than one argument is given, return only the first. Return nil if none are given.
Calculate cursor position in word wrapped content.
Returns whether the HTTP
session is to be kept alive.
Marshal
dumps exit locations to the given filename.
Usage:
If --yjit-exit-locations
is passed, a file named “yjit_exit_locations.dump” will automatically be generated.
If you want to collect traces manually, call dump_exit_locations
directly.
Note that calling this in a script will generate stats after the dump is created, so the stats data may include exits from the dump itself.
In a script call:
at_exit do RubyVM::YJIT.dump_exit_locations("my_file.dump") end
Then run the file with the following options:
ruby --yjit --yjit-trace-exits test.rb
Once the code is done running, use Stackprof to read the dump file. See Stackprof documentation for options.