Results for: "Dir.chdir"

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.

Paths where RubyGems’ .rb files and bin files are installed

Returns true if stat is a directory, false otherwise.

File.stat("testfile").directory?   #=> false
File.stat(".").directory?          #=> true

The path to the data directory for this gem.

Return the directories that Specification uses to find specs.

Set the directories that Specification uses to find specs. Setting this resets the list of known specs.

Yields all attributes (as symbols) along with the corresponding values or returns an enumerator if no block is given.

require "ostruct"
data = OpenStruct.new("country" => "Australia", :capital => "Canberra")
data.each_pair.to_a   # => [[:country, "Australia"], [:capital, "Canberra"]]

Calls the given block with each member name/value pair; returns self:

Customer = Struct.new(:name, :address, :zip) # => Customer
joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
joe.each_pair {|(name, value)| p "#{name} => #{value}" }

Output:

"name => Joe Smith"
"address => 123 Maple, Anytown NC"
"zip => 12345"

Returns an Enumerator if no block is given.

Related: each.

Calls the given block with each key-value pair; returns self:

h = {foo: 0, bar: 1, baz: 2}
h.each_pair {|key, value| puts "#{key}: #{value}"} # => {:foo=>0, :bar=>1, :baz=>2}

Output:

foo: 0
bar: 1
baz: 2

Returns a new Enumerator if no block given:

h = {foo: 0, bar: 1, baz: 2}
e = h.each_pair # => #<Enumerator: {:foo=>0, :bar=>1, :baz=>2}:each_pair>
h1 = e.each {|key, value| puts "#{key}: #{value}"}
h1 # => {:foo=>0, :bar=>1, :baz=>2}

Output:

foo: 0
bar: 1
baz: 2

Yields each environment variable name and its value as a 2-element Array:

h = {}
ENV.each_pair { |name, value| h[name] = value } # => ENV
h # => {"bar"=>"1", "foo"=>"0"}

Returns an Enumerator if no block given:

h = {}
e = ENV.each_pair # => #<Enumerator: {"bar"=>"1", "foo"=>"0"}:each_pair>
e.each { |name, value| h[name] = value } # => ENV
h # => {"bar"=>"1", "foo"=>"0"}

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.

No documentation available

Returns an array with bindir attached to each executable in the executables list

No documentation available

Returns a new Array containing only those elements from self that are not found in any of the Arrays other_arrays; items are compared using eql?; order from self is preserved:

[0, 1, 1, 2, 1, 1, 3, 1, 1].difference([1]) # => [0, 2, 3]
[0, 1, 2, 3].difference([3, 0], [1, 3]) # => [2]
[0, 1, 2].difference([4]) # => [0, 1, 2]

Returns a copy of self if no arguments given.

Related: Array#-.

Finds and returns the object in nested objects that is specified by index and identifiers. The nested objects may be instances of various classes. See Dig Methods.

Examples:

a = [:foo, [:bar, :baz, [:bat, :bam]]]
a.dig(1) # => [:bar, :baz, [:bat, :bam]]
a.dig(1, 2) # => [:bat, :bam]
a.dig(1, 2, 0) # => :bat
a.dig(1, 2, 3) # => nil

Returns elements from self; does not modify self.

When no argument is given, returns the first element:

a = [:foo, 'bar', 2]
a.first # => :foo
a # => [:foo, "bar", 2]

If self is empty, returns nil.

When non-negative Integer argument n is given, returns the first n elements in a new Array:

a = [:foo, 'bar', 2]
a.first(2) # => [:foo, "bar"]

If n >= array.size, returns all elements:

a = [:foo, 'bar', 2]
a.first(50) # => [:foo, "bar", 2]

If n == 0 returns an new empty Array:

a = [:foo, 'bar', 2]
a.first(0) # []

Related: last.

Performs integer division; returns the integer result of dividing self by numeric:

4.div(3)              # => 1
4.div(-3)             # => -2
-4.div(3)             # => -2
-4.div(-3)            # => 1
4.div(3.0)            # => 1
4.div(Rational(3, 1)) # => 1

Raises an exception if numeric does not have method div.

Returns a 2-element array [q, r], where

q = (self/other).floor    # Quotient
r = self % other          # Remainder

Examples:

11.divmod(4)              # => [2, 3]
11.divmod(-4)             # => [-3, -1]
-11.divmod(4)             # => [-3, 1]
-11.divmod(-4)            # => [2, -3]

12.divmod(4)              # => [3, 0]
12.divmod(-4)             # => [-3, 0]
-12.divmod(4)             # => [-3, 0]
-12.divmod(-4)            # => [3, 0]

13.divmod(4.0)            # => [3, 1.0]
13.divmod(Rational(4, 1)) # => [3, (1/1)]

Returns the Float result of dividing self by numeric:

4.fdiv(2)      # => 2.0
4.fdiv(-2)      # => -2.0
-4.fdiv(2)      # => -2.0
4.fdiv(2.0)      # => 2.0
4.fdiv(Rational(3, 4))      # => 5.333333333333333

Raises an exception if numeric cannot be converted to a Float.

Returns an array of integers representing the base-radix digits of self; the first element of the array represents the least significant digit:

12345.digits      # => [5, 4, 3, 2, 1]
12345.digits(7)   # => [4, 6, 6, 0, 5]
12345.digits(100) # => [45, 23, 1]

Raises an exception if self is negative or base is less than 2.

Returns the result of division self by numeric. rounded up to the nearest integer.

3.ceildiv(3)   # => 1
4.ceildiv(3)   # => 2

4.ceildiv(-3)  # => -1
-4.ceildiv(3)  # => -1
-4.ceildiv(-3) # => 2

3.ceildiv(1.2) # => 3

Returns Complex.rect(self.real/numeric, self.imag/numeric):

Complex.rect(11, 22).fdiv(3) # => (3.6666666666666665+7.333333333333333i)

Returns the quotient self/other as a float, using method / in the derived class of self. (Numeric itself does not define method /.)

Of the Core and Standard Library classes, only BigDecimal uses this implementation.

Returns the quotient self/other as an integer (via floor), using method / in the derived class of self. (Numeric itself does not define method /.)

Of the Core and Standard Library classes, Only Float and Rational use this implementation.

Search took: 3ms  ·  Total Results: 1022