If stat is writable by others, returns an integer representing the file permission bits of stat. Returns nil
otherwise. The meaning of the bits is platform dependent; on Unix systems, see stat(2)
.
m = File.stat("/tmp").world_writable? #=> 511 sprintf("%o", m) #=> "777"
Same as executable?
, but tests using the real owner of the process.
Removes fields from self
as selected by the block; returns self
.
Removes each field for which the block returns a truthy value:
source = "Name,Name,Name\nFoo,Bar,Baz\n" table = CSV.parse(source, headers: true) row = table[0] row.delete_if {|header, value| value.start_with?('B') } # => true row # => #<CSV::Row "Name":"Foo"> row.delete_if {|header, value| header.start_with?('B') } # => false
If no block is given, returns a new Enumerator:
row.delete_if # => #<Enumerator: #<CSV::Row "Name":"Foo">:delete_if>
Removes rows or columns for which the block returns a truthy value; returns self
.
Removes rows when the access mode is :row
or :col_or_row
; calls the block with each CSV::Row object:
source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n" table = CSV.parse(source, headers: true) table.by_row! # => #<CSV::Table mode:row row_count:4> table.size # => 3 table.delete_if {|row| row['Name'].start_with?('b') } table.size # => 1
Removes columns when the access mode is :col
; calls the block with each column as a 2-element array containing the header and an Array of column fields:
source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n" table = CSV.parse(source, headers: true) table.by_col! # => #<CSV::Table mode:col row_count:4> table.headers.size # => 2 table.delete_if {|column_data| column_data[1].include?('2') } table.headers.size # => 1
Returns a new Enumerator if no block is given:
source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n" table = CSV.parse(source, headers: true) table.delete_if # => #<Enumerator: #<CSV::Table mode:col_or_row row_count:4>:delete_if>
Has a method been included in the list of insecure methods?
Returns intger 80
, the default port to use for HTTP
requests:
Net::HTTP.default_port # => 80
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
.
Sym#useless?
, Rule#useless?
FIXME: what means “useless”?