Returns true
; retained for compatibility.
Creates a new Net::HTTP object, http
, via Net::HTTP.new:
Net::HTTP.new(address, port, p_addr, p_port, p_user, p_pass)
For arguments hostname
through p_pass
, see Net::HTTP.new
.
For argument opts
, see below.
Note: If port
is nil
and opts[:use_ssl]
is a truthy value, the value passed to new
is Net::HTTP.https_default_port
, not port
.
With no block given:
Calls http.start
with no block (see start
), which opens a TCP connection and HTTP session.
Returns http
.
The caller should call finish
to close the session:
http = Net::HTTP.start(hostname) http.started? # => true http.finish http.started? # => false
With a block given:
Calls http.start
with the block (see start
), which:
Opens a TCP connection and HTTP session.
Calls the block, which may make any number of requests to the host.
Closes the HTTP session and TCP connection on block exit.
Returns the block’s value object
.
Returns object
.
Example:
hostname = 'jsonplaceholder.typicode.com' Net::HTTP.start(hostname) do |http| puts http.get('/todos/1').body puts http.get('/todos/2').body end
Output:
{ "userId": 1, "id": 1, "title": "delectus aut autem", "completed": false } { "userId": 1, "id": 2, "title": "quis ut nam facilis et officia qui", "completed": false }
If the last argument given is a hash, it is the opts
hash, where each key is a method or accessor to be called, and its value is the value to be set.
The keys may include:
Returns true if the HTTP
session has been started.
Opens a TCP connection and HTTP
session.
When this method is called with a block, it passes the Net::HTTP
object to the block, and closes the TCP connection and HTTP
session after the block has been executed.
When called with a block, it returns the return value of the block; otherwise, it returns self.
Sets the resolver timeouts. This may be a single positive number or an array of positive numbers representing timeouts in seconds. If an array is specified, a DNS
request will retry and wait for each successive interval in the array until a successful response is received. Specifying nil
reverts to the default timeouts:
Example:
dns.timeouts = 3
Registers for notifications of event ev
on the proxied TupleSpace
. See TupleSpace#notify
Called by TupleSpace
to notify this NotifyTemplateEntry
of a new event.
Registers for notifications of event
. Returns a NotifyTemplateEntry
. See NotifyTemplateEntry
for examples of how to listen for notifications.
event
can be:
A tuple was added
A tuple was taken or moved
A tuple was lost after being overwritten or expiring
The TupleSpace
will also notify you of the ‘close’ event when the NotifyTemplateEntry
has expired.
True when the gem has been activated
Version of the gem
Create on demand parser.
The Requirement of the unresolved dependency (not Version).
Ensure path
and path with extension
are identical.
Parse obj
, returning an [op, version]
pair. obj
can be a String
or a Gem::Version
.
If obj
is a String
, it can be either a full requirement specification, like ">= 1.2"
, or a simple version number, like "1.2"
.
parse("> 1.0") # => [">", Gem::Version.new("1.0")] parse("1.0") # => ["=", Gem::Version.new("1.0")] parse(Gem::Version.new("1.0")) # => ["=, Gem::Version.new("1.0")]
A string representation of this Version
.
Extensions to build when installing the gem, specifically the paths to extconf.rb-style files used to compile extensions.
These files will be run when the gem is installed, causing the C (or whatever) code to be compiled on the user’s machine.
Usage:
spec.extensions << 'ext/rmagic/extconf.rb'
See Gem::Ext::Builder
for information about writing extensions for gems.