When allow_prerelease
is set to true
prereleases gems are allowed to match dependencies.
Sets the remote network access for all composed sets.
Remove the oldest DependencyRequest from the list.
Returns a challenge response which asks for authentication information
Returns a challenge response which asks for authentication information
Returns the HTTP status code
Tries to convert obj
into an array, using to_ary
method. Returns the converted array or nil
if obj
cannot be converted for any reason. This method can be used to check if an argument is an array.
Array.try_convert([1]) #=> [1] Array.try_convert("1") #=> nil if tmp = Array.try_convert(arg) # the argument is an array elsif tmp = String.try_convert(arg) # the argument is a string end
Replaces the contents of self
with the contents of other_ary
, truncating or expanding if necessary.
a = [ "a", "b", "c", "d", "e" ] a.replace([ "x", "y", "z" ]) #=> ["x", "y", "z"] a #=> ["x", "y", "z"]
Returns an integer identifier for obj
.
The same number will be returned on all calls to object_id
for a given object, and no two active objects will share an id.
Note: that some objects of builtin classes are reused for optimization. This is the case for immediate values and frozen string literals.
Immediate values are not passed by reference but are passed by value: nil
, true
, false
, Fixnums, Symbols, and some Floats.
Object.new.object_id == Object.new.object_id # => false (21 * 2).object_id == (21 * 2).object_id # => true "hello".object_id == "hello".object_id # => false "hi".freeze.object_id == "hi".freeze.object_id # => true
Returns true
if obj is an instance of the given class. See also Object#kind_of?
.
class A; end class B < A; end class C < B; end b = B.new b.instance_of? A #=> false b.instance_of? B #=> true b.instance_of? C #=> false
Returns true
if obj responds to the given method. Private and protected methods are included in the search only if the optional second parameter evaluates to true
.
If the method is not implemented, as Process.fork
on Windows, File.lchmod
on GNU/Linux, etc., false is returned.
If the method is not defined, respond_to_missing?
method is called and the result is returned.
When the method name parameter is given as a string, the string is converted to a symbol.
Returns a hash, that will be turned into a JSON
object and represent this object.
Try to convert obj into a String, using to_str
method. Returns converted string or nil if obj cannot be converted for any reason.
String.try_convert("str") #=> "str" String.try_convert(/re/) #=> nil
Replaces the contents and taintedness of str with the corresponding values in other_str.
s = "hello" #=> "hello" s.replace "world" #=> "world"
Returns true for a string which has only ASCII characters.
"abc".force_encoding("UTF-8").ascii_only? #=> true "abc\u{6666}".force_encoding("UTF-8").ascii_only? #=> false
Iterates the given block for each element with an arbitrary object, obj
, and returns obj
If no block is given, returns a new Enumerator
.
to_three = Enumerator.new do |y| 3.times do |x| y << x end end to_three_with_string = to_three.with_object("foo") to_three_with_string.each do |x,string| puts "#{string}: #{x}" end # => foo:0 # => foo:1 # => foo:2
Deserializes JSON
string by constructing new Exception
object with message m
and backtrace b
serialized with to_json
Returns a hash, that will be turned into a JSON
object and represent this object.