Returns true if the set is a subset of the given set.
Deletes every element that appears in the given enumerable object and returns self.
Returns an array of classes where the receiver is the direct superclass of the class, excluding singleton classes. The order of the returned array is not defined.
class A; end class B < A; end class C < B; end class D < A; end A.subclasses #=> [D, B] B.subclasses #=> [C] C.subclasses #=> []
Anonymous subclasses (not associated with a constant) are returned, too:
c = Class.new(A) A.subclasses # => [#<Class:0x00007f003c77bd78>, D, B]
Note that the parent does not hold references to subclasses and doesn’t prevent them from being garbage collected. This means that the subclass might disappear when all references to it are dropped:
# drop the reference to subclass, it can be garbage-collected now c = nil A.subclasses # It can be # => [#<Class:0x00007f003c77bd78>, D, B] # ...or just # => [D, B] # ...depending on whether garbage collector was run
Return a pathname which is substituted by String#sub
.
path1 = Pathname.new('/usr/bin/perl') path1.sub('perl', 'ruby') #=> #<Pathname:/usr/bin/ruby>
Equivalent to $_.sub(args)
, except that $_
will be updated if substitution occurs. Available only when -p/-n command line option specified.
Quietly ensure the Gem directory dir
contains all the proper subdirectories. If we can’t create a directory due to a permission problem, then we will silently continue.
If mode
is given, missing directories are created with this mode.
World-writable directories will never be created.
Quietly ensure the Gem directory dir
contains all the proper subdirectories for handling default gems. If we can’t create a directory due to a permission problem, then we will silently continue.
If mode
is given, missing directories are created with this mode.
World-writable directories will never be created.
Returns true if the set is a proper subset of the given set.
Return a pathname with repl
added as a suffix to the basename.
If self has no extension part, repl
is appended.
Pathname.new('/usr/bin/shutdown').sub_ext('.rb') #=> #<Pathname:/usr/bin/shutdown.rb>
Takes a block and queues a new group that is indented 1 level further.
Generate a submit button Input element, as a String
.
value
is the text to display on the button. name
is the name of the input.
Alternatively, the attributes can be specified as a hash.
submit # <INPUT TYPE="submit"> submit("ok") # <INPUT TYPE="submit" VALUE="ok"> submit("ok", "button1") # <INPUT TYPE="submit" VALUE="ok" NAME="button1"> submit("VALUE" => "ok", "NAME" => "button1", "ID" => "foo") # <INPUT TYPE="submit" VALUE="ok" NAME="button1" ID="foo">
Create a new ForwardingSuperNode
node
Returns the trailing (‘subtype’) part of the media type from the value of field 'Content-Type'
, or nil
if no such field exists; see Content-Type response header:
res = Net::HTTP.get_response(hostname, '/todos/1') res['content-type'] # => "application/json; charset=utf-8" res.sub_type # => "json"
Returns true if other
is a subdomain.
Example:
domain = Resolv::DNS::Name.create("y.z") p Resolv::DNS::Name.create("w.x.y.z").subdomain_of?(domain) #=> true p Resolv::DNS::Name.create("x.y.z").subdomain_of?(domain) #=> true p Resolv::DNS::Name.create("y.z").subdomain_of?(domain) #=> false p Resolv::DNS::Name.create("z").subdomain_of?(domain) #=> false p Resolv::DNS::Name.create("x.y.z.").subdomain_of?(domain) #=> false p Resolv::DNS::Name.create("w.z").subdomain_of?(domain) #=> false
When no block is given, returns the object equivalent to:
sum = init array.each {|element| sum += element } sum
For example, [e1, e2, e3].sum
returns init + e1 + e2 + e3
.
Examples:
a = [0, 1, 2, 3] a.sum # => 6 a.sum(100) # => 106
The elements need not be numeric, but must be +
-compatible with each other and with init
:
a = ['abc', 'def', 'ghi'] a.sum('jkl') # => "jklabcdefghi"
When a block is given, it is called with each element and the block’s return value (instead of the element itself) is used as the addend:
a = ['zero', 1, :two] s = a.sum('Coerced and concatenated: ') {|element| element.to_s } s # => "Coerced and concatenated: zero1two"
Notes:
Array#join
and Array#flatten
may be faster than Array#sum
for an Array of Strings or an Array of Arrays.
Array#sum
method may not respect method redefinition of “+” methods such as Integer#+
.
Returns the successor integer of self
(equivalent to self + 1
):
1.succ #=> 2 -1.succ #=> 0
Related: Integer#pred
(predecessor value).