Results for: "Dir.chdir"

Loads the given name, returning true if successful and false if the feature is already loaded.

If the filename neither resolves to an absolute path nor starts with ‘./’ or ‘../’, the file will be searched for in the library directories listed in $LOAD_PATH ($:). If the filename starts with ‘./’ or ‘../’, resolution is based on Dir.pwd.

If the filename has the extension “.rb”, it is loaded as a source file; if the extension is “.so”, “.o”, or “.dll”, or the default shared library extension on the current platform, Ruby loads the shared library as a Ruby extension. Otherwise, Ruby tries adding “.rb”, “.so”, and so on to the name until found. If the file named cannot be found, a LoadError will be raised.

For Ruby extensions the filename given may use any shared library extension. For example, on Linux the socket extension is “socket.so” and require 'socket.dll' will load the socket extension.

The absolute path of the loaded file is added to $LOADED_FEATURES ($"). A file will not be loaded again if its path already appears in $". For example, require 'a'; require './a' will not load a.rb again.

require "my-library.rb"
require "db-driver"

Any constants or globals within the loaded source file will be available in the calling program’s global namespace. However, local variables will not be propagated to the loading environment.

Returns a Binding object, describing the variable and method bindings at the point of call. This object can be used when calling eval to execute the evaluated command in this environment. See also the description of class Binding.

def get_binding(param)
  binding
end
b = get_binding("hello")
eval("param", b)   #=> "hello"

Returns the first element or elements.

With no argument, returns the first element, or nil if there is none:

(1..4).first                   # => 1
%w[a b c].first                # => "a"
{foo: 1, bar: 1, baz: 2}.first # => [:foo, 1]
[].first                       # => nil

With integer argument n, returns an array containing the first n elements that exist:

(1..4).first(2)                   # => [1, 2]
%w[a b c d].first(3)              # => ["a", "b", "c"]
%w[a b c d].first(50)             # => ["a", "b", "c", "d"]
{foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]]
[].first(2)                       # => []

Returns a Digest subclass by name

require 'openssl'

OpenSSL::Digest("MD5")
# => OpenSSL::Digest::MD5

Digest("Foo")
# => NameError: wrong constant name Foo

Returns a Digest subclass by name

require 'openssl'

OpenSSL::Digest("MD5")
# => OpenSSL::Digest::MD5

Digest("Foo")
# => NameError: wrong constant name Foo

Change what’s displayed on the screen to reflect the current contents.

See GNU Readline’s rl_redisplay function.

Raises NotImplementedError if the using readline library does not support.

Disables garbage collection, returning true if garbage collection was already disabled.

GC.disable   #=> false
GC.disable   #=> true

Creates a new directory in the tar file name with mode

Returns a string usable in Dir.glob to match all requirable paths for this spec.

Make directories for index generation

No documentation available

Iterates over keys and objects in a weakly referenced object

No documentation available

Calls the given block once for each key, value pair in the database.

Returns self.

@api private

Copied from ExtConfBuilder

No documentation available

Passes each character in str to the given block, or returns an enumerator if no block is given.

"hello".each_char {|c| print c, ' ' }

produces:

h e l l o

Changes the encoding to encoding and returns self.

Returns true for a string which is encoded correctly.

"\xc2\xa1".force_encoding("UTF-8").valid_encoding?  #=> true
"\xc2".force_encoding("UTF-8").valid_encoding?      #=> false
"\x80".force_encoding("UTF-8").valid_encoding?      #=> false

Returns the number of decimal significant digits in self.

BigDecimal("0").scale         # => 0
BigDecimal("1").scale         # => 1
BigDecimal("1.1").scale       # => 2
BigDecimal("3.1415").scale    # => 5
BigDecimal("-1e20").precision # => 1
BigDecimal("1e-20").precision # => 1
BigDecimal("Infinity").scale  # => 0
BigDecimal("-Infinity").scale # => 0
BigDecimal("NaN").scale       # => 0

Converts a BigDecimal to a String of the form “nnnnnn.mmm”. This method is deprecated; use BigDecimal#to_s(“F”) instead.

require 'bigdecimal/util'

d = BigDecimal("3.14")
d.to_digits                  # => "3.14"

Returns true if the given ordinal date is valid, and false if not.

Date.valid_ordinal?(2001,34)      #=> true
Date.valid_ordinal?(2001,366)     #=> false

See also ::jd and ::ordinal.

No documentation available

Calls the given block once for each character in ios, passing the character as an argument. The stream must be opened for reading or an IOError will be raised.

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

f = File.new("testfile")
f.each_char {|c| print c, ' ' }   #=> #<File:testfile>
Search took: 3ms  ·  Total Results: 1057