Compile a RationalNode
node
Dispatch enter and leave events for RationalNode
nodes and continue walking the tree.
Inspect a RationalNode
node.
Add the –prerelease option to the option parser.
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.
The current session cache mode.
Sets the SSL
session cache mode. Bitwise-or together the desired SESSION_CACHE_* constants to set. See SSL_CTX_set_session_cache_mode(3) for details.
Like Enumerable#map
, but chains operation to be lazy-evaluated.
(1..Float::INFINITY).lazy.map {|i| i**2 } #=> #<Enumerator::Lazy: #<Enumerator::Lazy: 1..Infinity>:map> (1..Float::INFINITY).lazy.map {|i| i**2 }.first(3) #=> [1, 4, 9]
Like Enumerable#select
, but chains operation to be lazy-evaluated.
Sets the encoding that should be used when reading the body:
If the given value is an Encoding
object, that encoding will be used.
Otherwise if the value is a string, the value of Encoding#find(value) will be used.
Otherwise an encoding will be deduced from the body itself.
Examples:
http = Net::HTTP.new(hostname) req = Net::HTTP::Get.new('/') http.request(req) do |res| p res.body.encoding # => #<Encoding:ASCII-8BIT> end http.request(req) do |res| res.body_encoding = "UTF-8" p res.body.encoding # => #<Encoding:UTF-8> end
Removes the named instance variable from obj, returning that variable’s value. The name can be passed as a symbol or as a string.
class Dummy attr_reader :var def initialize @var = 99 end def remove remove_instance_variable(:@var) end end d = Dummy.new d.var #=> 99 d.remove #=> 99 d.var #=> nil
Defines a public singleton method in the receiver. The method parameter can be a Proc
, a Method
or an UnboundMethod
object. If a block is specified, it is used as the method body. If a block or a method has parameters, they’re used as method parameters.
class A class << self def class_name to_s end end end A.define_singleton_method(:who_am_i) do "I am: #{class_name}" end A.who_am_i # ==> "I am: A" guy = "Bob" guy.define_singleton_method(:hello) { "#{self}: Hello there!" } guy.hello #=> "Bob: Hello there!" chris = "Chris" chris.define_singleton_method(:greet) {|greeting| "#{greeting}, I'm Chris!" } chris.greet("Hi") #=> "Hi, I'm Chris!"