Zlib::GzipWriter
wrapper that zips data
.
Set
the real user ID of the calling process to user. Not available on all platforms.
Set
the real group ID of the calling process to group. Not available on all platforms.
Sets the (user) real and/or effective user IDs of the current process to rid and eid, respectively. A value of -1
for either means to leave that ID unchanged. Not available on all platforms.
Sets the (group) real and/or effective group IDs of the current process to rid and eid, respectively. A value of -1
for either means to leave that ID unchanged. Not available on all platforms.
Sets the (user) real, effective, and saved user IDs of the current process to rid, eid, and sid respectively. A value of -1
for any value means to leave that ID unchanged. Not available on all platforms.
Sets the (group) real, effective, and saved user IDs of the current process to rid, eid, and sid respectively. A value of -1
for any value means to leave that ID unchanged. Not available on all platforms.
Foo ||= bar
becomes
defined?(Foo) ? Foo : Foo = bar
Reset nil attributes to their default values to make the spec valid
@foo = 1 ^^^^^^^^
@foo = 1 ^^^^^^^^
@foo, @bar = 1 ^^^^ ^^^^
Attempts to return an array, based on the given object
.
If object
is an array, returns object
.
Otherwise if object
responds to :to_ary
. calls object.to_ary
: if the return value is an array or nil
, returns that value; if not, raises TypeError
.
Otherwise returns nil
.
If object
is an Integer object, returns object
.
Integer.try_convert(1) # => 1
Otherwise if object
responds to :to_int
, calls object.to_int
and returns the result.
Integer.try_convert(1.25) # => 1
Returns nil
if object
does not respond to :to_int
Integer.try_convert([]) # => nil
Raises an exception unless object.to_int
returns an Integer object.
If object
is a String
object, returns object
.
Otherwise if object
responds to :to_str
, calls object.to_str
and returns the result.
Returns nil
if object
does not respond to :to_str
.
Raises an exception unless object.to_str
returns a String
object.
Returns an array of the grapheme clusters in self
(see Unicode Grapheme Cluster Boundaries):
s = "\u0061\u0308-pqr-\u0062\u0308-xyz-\u0063\u0308" # => "ä-pqr-b̈-xyz-c̈" s.grapheme_clusters # => ["ä", "-", "p", "q", "r", "-", "b̈", "-", "x", "y", "z", "-", "c̈"]
Returns whether self
starts with any of the given string_or_regexp
.
Matches patterns against the beginning of self
. For each given string_or_regexp
, the pattern is:
string_or_regexp
itself, if it is a Regexp
.
Regexp.quote(string_or_regexp)
, if string_or_regexp
is a string.
Returns true
if any pattern matches the beginning, false
otherwise:
'hello'.start_with?('hell') # => true 'hello'.start_with?(/H/i) # => true 'hello'.start_with?('heaven', 'hell') # => true 'hello'.start_with?('heaven', 'paradise') # => false 'тест'.start_with?('т') # => true 'こんにちは'.start_with?('こ') # => true
Related: String#end_with?
.
Like String#tr_s
, but modifies self
in place. Returns self
if any changes were made, nil
otherwise.
Related: String#squeeze!
.
Like backtrace
, but returns each line of the execution stack as a Thread::Backtrace::Location
. Accepts the same arguments as backtrace
.
f = Fiber.new { Fiber.yield } f.resume loc = f.backtrace_locations.first loc.label #=> "yield" loc.path #=> "test.rb" loc.lineno #=> 1
Returns true
if the named file is writable by the real user and group id of this process. See access(3).
Note that some OS-level security features may cause this to return true even though the file is not writable by the real user/group.