Delete the session from storage. Also closes the storage.
Note that the session’s data is not automatically deleted upon the session expiring.
Removes a specified field from self
; returns the 2-element Array [header, value]
if the field exists.
If an Integer argument index
is given, removes and returns the field at offset index
, or returns nil
if the field does not exist:
source = "Name,Name,Name\nFoo,Bar,Baz\n" table = CSV.parse(source, headers: true) row = table[0] row.delete(1) # => ["Name", "Bar"] row.delete(50) # => nil
Otherwise, if the single argument header
is given, removes and returns the first-found field with the given header, of returns a new empty Array if the field does not exist:
source = "Name,Name,Name\nFoo,Bar,Baz\n" table = CSV.parse(source, headers: true) row = table[0] row.delete('Name') # => ["Name", "Foo"] row.delete('NAME') # => []
If argument header
and Integer argument offset
are given, removes and returns the first-found field with the given header whose index
is at least as large as offset
:
source = "Name,Name,Name\nFoo,Bar,Baz\n" table = CSV.parse(source, headers: true) row = table[0] row.delete('Name', 1) # => ["Name", "Bar"] row.delete('NAME', 1) # => []
If the access mode is :row
or :col_or_row
, and each argument is either an Integer or a Range, returns deleted rows. Otherwise, returns deleted columns data.
In either case, the returned values are in the order specified by the arguments. Arguments may be repeated.
Returns rows as an Array of CSV::Row objects.
One index:
source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n" table = CSV.parse(source, headers: true) deleted_values = table.delete(0) deleted_values # => [#<CSV::Row "Name":"foo" "Value":"0">]
Two indexes:
table = CSV.parse(source, headers: true) deleted_values = table.delete(2, 0) deleted_values # => [#<CSV::Row "Name":"baz" "Value":"2">, #<CSV::Row "Name":"foo" "Value":"0">]
Returns columns data as column Arrays.
One header:
table = CSV.parse(source, headers: true) deleted_values = table.delete('Name') deleted_values # => ["foo", "bar", "baz"]
Two headers:
table = CSV.parse(source, headers: true) deleted_values = table.delete('Value', 'Name') deleted_values # => [["0", "1", "2"], ["foo", "bar", "baz"]]
Sends a DELETE request to the path
and gets a response, as an HTTPResponse
object.
Sends a MOVE request to the path
and gets a response, as an HTTPResponse
object.
Returns the full entity body.
Calling this method a second or subsequent time will return the string already read.
http.request_get('/index.html') {|res| puts res.body } http.request_get('/index.html') {|res| p res.body.object_id # 538149362 p res.body.object_id # 538149362 }
Because it may be necessary to modify the body, Eg, decompression this method facilitates that.
v
Public setter for the typecode v
(with validation).
See also URI::FTP.check_typecode
.
require 'uri' uri = URI.parse("ftp://john@ftp.example.com/my_file.img") #=> #<URI::FTP ftp://john@ftp.example.com/my_file.img> uri.typecode = "i" uri #=> #<URI::FTP ftp://john@ftp.example.com/my_file.img;type=i>
Searches list id
for opt
and the optional patterns for completion pat
. If icase
is true, the search is case insensitive. The result is returned or yielded if a block is given. If it isn’t found, nil is returned.
Appends sep
to the text to be output. By default sep
is ‘ ’
width
argument is here for compatibility. It is a noop argument.