Takes source
, which can be a string of Ruby
code, or an open File
object. that contains Ruby
source code. It parses and compiles using parse.y.
Optionally takes file
, path
, and line
which describe the file path, real path and first line number of the ruby code in source
which are metadata attached to the returned iseq
.
file
is used for ‘__FILE__` and exception backtrace. path
is used for require_relative
base. It is recommended these should be the same full path.
options
, which can be true
, false
or a Hash
, is used to modify the default behavior of the Ruby
iseq compiler.
For details regarding valid compile options see ::compile_option=
.
RubyVM::InstructionSequence.compile_parsey("a = 1 + 2") #=> <RubyVM::InstructionSequence:<compiled>@<compiled>> path = "test.rb" RubyVM::InstructionSequence.compile_parsey(File.read(path), path, File.expand_path(path)) #=> <RubyVM::InstructionSequence:<compiled>@test.rb:1> file = File.open("test.rb") RubyVM::InstructionSequence.compile_parsey(file) #=> <RubyVM::InstructionSequence:<compiled>@<compiled>:1> path = File.expand_path("test.rb") RubyVM::InstructionSequence.compile_parsey(File.read(path), path, path) #=> <RubyVM::InstructionSequence:<compiled>@/absolute/path/to/test.rb:1>
Takes source
, which can be a string of Ruby
code, or an open File
object. that contains Ruby
source code. It parses and compiles using prism.
Optionally takes file
, path
, and line
which describe the file path, real path and first line number of the ruby code in source
which are metadata attached to the returned iseq
.
file
is used for ‘__FILE__` and exception backtrace. path
is used for require_relative
base. It is recommended these should be the same full path.
options
, which can be true
, false
or a Hash
, is used to modify the default behavior of the Ruby
iseq compiler.
For details regarding valid compile options see ::compile_option=
.
RubyVM::InstructionSequence.compile_prism("a = 1 + 2") #=> <RubyVM::InstructionSequence:<compiled>@<compiled>> path = "test.rb" RubyVM::InstructionSequence.compile_prism(File.read(path), path, File.expand_path(path)) #=> <RubyVM::InstructionSequence:<compiled>@test.rb:1> file = File.open("test.rb") RubyVM::InstructionSequence.compile_prism(file) #=> <RubyVM::InstructionSequence:<compiled>@<compiled>:1> path = File.expand_path("test.rb") RubyVM::InstructionSequence.compile_prism(File.read(path), path, path) #=> <RubyVM::InstructionSequence:<compiled>@/absolute/path/to/test.rb:1>
Returns integer 80
, the default port to use for HTTP requests:
Net::HTTP.default_port # => 80
Returns integer 80
, the default port to use for HTTP requests:
Net::HTTP.default_port # => 80
Sets the body stream for the request:
req = Net::HTTP::Post.new(uri) # => #<Net::HTTP::Post POST> req.body_stream # => nil require 'stringio' req.body_stream = StringIO.new('xyzzy') # => #<StringIO:0x0000027d1e5affa8> req.body_stream # => #<StringIO:0x0000027d1e5affa8>
true if the response has a body.
Gets the entity body returned by the remote HTTP server.
If a block is given, the body is passed to the block, and the body is provided in fragments, as it is read in from the socket.
If dest
argument is given, response is read into that variable, with dest#<<
method (it could be String
or IO
, or any other object responding to <<
).
Calling this method a second or subsequent time for the same HTTPResponse
object will return the value already read.
http.request_get('/index.html') {|res| puts res.read_body } http.request_get('/index.html') {|res| p res.read_body.object_id # 538149362 p res.read_body.object_id # 538149362 } # using iterator http.request_get('/index.html') {|res| res.read_body do |segment| print segment end }
Validates typecode v
, returns true
or false
.
Mirrors the C extension’s StringQuery::method_name?
method.
Whether or not this string is a valid method name.
These are the comments that are associated with this location that exist before the start of this location.
Attach a comment to the leading comments of this location.
Raise an error because the given node is not supported.
Override to display the default values of the command options. (similar to arguments
, but displays the default values).
For example:
def defaults_str --no-gems-first --no-all end
Handle the command arguments.
The location of the spec file that is installed.
Verifies the files of the gem