Results for: "module_function"

Used to detect if the gem is bundled in older version of Ruby, but not detectable as default gem (see BasicSpecification#default_gem?).

UNTESTED

Returns true if the content needs to be encoded in base64.

No documentation available

Returns int modulo other.

See Numeric#divmod for more information.

x.modulo(y) means x-y*(x/y).floor

Equivalent to num.divmod(numeric)[1].

See Numeric#divmod.

Return the modulo after division of float by other.

6543.21.modulo(137)      #=> 104.21
6543.21.modulo(137.24)   #=> 92.9299999999996

Returns the modulus from dividing by b.

See BigDecimal#divmod.

Returns int modulo other.

See Numeric#divmod for more information.

Returns garbage collector generation for the given object.

class B
  include ObjectSpace

  def foo
    trace_object_allocations do
      obj = Object.new
      p "Generation is #{allocation_generation(obj)}"
    end
  end
end

B.new.foo #=> "Generation is 3"

See ::trace_object_allocations for more information and examples.

Searches sep or pattern (regexp) in the string and returns the part before it, the match, and the part after it. If it is not found, returns two empty strings and str.

"hello".partition("l")         #=> ["he", "l", "lo"]
"hello".partition("x")         #=> ["hello", "", ""]
"hello".partition(/.l/)        #=> ["h", "el", "lo"]

Searches sep or pattern (regexp) in the string from the end of the string, and returns the part before it, the match, and the part after it. If it is not found, returns two empty strings and str.

"hello".rpartition("l")         #=> ["hel", "l", "o"]
"hello".rpartition("x")         #=> ["", "", "hello"]
"hello".rpartition(/.l/)        #=> ["he", "ll", "o"]

Opens a new transaction for the data store. Code executed inside a block passed to this method may read and write data to and from the data store file.

At the end of the block, changes are committed to the data store automatically. You may exit the transaction early with a call to either PStore#commit or PStore#abort. See those methods for details about how changes are handled. Raising an uncaught Exception in the block is equivalent to calling PStore#abort.

If read_only is set to true, you will only be allowed to read from the data store during the transaction and any attempts to change the data will raise a PStore::Error.

Note that PStore does not support nested transactions.

No documentation available

Returns two arrays, the first containing the elements of enum for which the block evaluates to true, the second containing the rest.

If no block is given, an enumerator is returned instead.

(1..6).partition { |v| v.even? }  #=> [[2, 4, 6], [1, 3, 5]]

The standard configuration object for gems.

Use the given configuration object (which implements the ConfigFile protocol) as the standard configuration object.

Returns the fractional part of the second.

DateTime.new(2001,2,3,4,5,6.5).sec_fraction       #=> (1/2)

Specifies a Proc object proc to determine if a character in the user’s input is escaped. It should take the user’s input and the index of the character in question as input, and return a boolean (true if the specified character is escaped).

Readline will only call this proc with characters specified in completer_quote_characters, to discover if they indicate the end of a quoted argument, or characters specified in completer_word_break_characters, to discover if they indicate a break between arguments.

If completer_quote_characters is not set, or if the user input doesn’t contain one of the completer_quote_characters or a ++ character, Readline will not attempt to use this proc at all.

Raises ArgumentError if proc does not respond to the call method.

Returns the quoting detection Proc object.

Returns the fractional part of the day.

DateTime.new(2001,2,3,12).day_fraction    #=> (1/2)

Returns the fractional part of the second.

DateTime.new(2001,2,3,4,5,6.5).sec_fraction       #=> (1/2)

Raises PStore::Error if the calling code is not in a PStore#transaction.

When invoked with a block, yield all permutations of length n of the elements of the array, then return the array itself.

If n is not specified, yield all permutations of all elements.

The implementation makes no guarantees about the order in which the permutations are yielded.

If no block is given, an Enumerator is returned instead.

Examples:

a = [1, 2, 3]
a.permutation.to_a    #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
a.permutation(1).to_a #=> [[1],[2],[3]]
a.permutation(2).to_a #=> [[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]]
a.permutation(3).to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
a.permutation(0).to_a #=> [[]] # one permutation of length 0
a.permutation(4).to_a #=> []   # no permutations of length 4

When invoked with a block, yields all combinations of length n of elements from the array and then returns the array itself.

The implementation makes no guarantees about the order in which the combinations are yielded.

If no block is given, an Enumerator is returned instead.

Examples:

a = [1, 2, 3, 4]
a.combination(1).to_a  #=> [[1],[2],[3],[4]]
a.combination(2).to_a  #=> [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]
a.combination(3).to_a  #=> [[1,2,3],[1,2,4],[1,3,4],[2,3,4]]
a.combination(4).to_a  #=> [[1,2,3,4]]
a.combination(0).to_a  #=> [[]] # one combination of length 0
a.combination(5).to_a  #=> []   # no combinations of length 5
Search took: 5ms  ·  Total Results: 3509