Results for: "module_function"

Removes all hash entries; returns self.

Deletes the environment variable with name if it exists and returns its value:

ENV['foo'] = '0'
ENV.delete('foo') # => '0'

If a block is not given and the named environment variable does not exist, returns nil.

If a block given and the environment variable does not exist, yields name to the block and returns the value of the block:

ENV.delete('foo') { |name| name * 2 } # => "foofoo"

If a block given and the environment variable exists, deletes the environment variable and returns its value (ignoring the block):

ENV['foo'] = '0'
ENV.delete('foo') { |name| raise 'ignored' } # => "0"

Raises an exception if name is invalid. See Invalid Names and Values.

Removes every environment variable; returns ENV:

ENV.replace('foo' => '0', 'bar' => '1')
ENV.size # => 2
ENV.clear # => ENV
ENV.size # => 0

Returns the count of environment variables:

ENV.replace('foo' => '0', 'bar' => '1')
ENV.length # => 2
ENV.size # => 2

Raises TypeError, because ENV is a singleton object. Use to_h to get a copy of ENV data as a hash.

Returns an integer representing the numeric file descriptor for the current file. Raises an ArgumentError if there isn’t a current file.

ARGF.fileno    #=> 3

Returns the current filename. “-” is returned when the current file is STDIN.

For example:

$ echo "foo" > foo
$ echo "bar" > bar
$ echo "glark" > glark

$ ruby argf.rb foo bar glark

ARGF.filename  #=> "foo"
ARGF.read(5)   #=> "foo\nb"
ARGF.filename  #=> "bar"
ARGF.skip
ARGF.filename  #=> "glark"

Returns the current file as an IO or File object. $stdin is returned when the current file is STDIN.

For example:

$ echo "foo" > foo
$ echo "bar" > bar

$ ruby argf.rb foo bar

ARGF.file      #=> #<File:foo>
ARGF.read(5)   #=> "foo\nb"
ARGF.file      #=> #<File:bar>

Calls CSV.read with source, options, and certain default options:

Returns a CSV::Table object.

Example:

string = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
path = 't.csv'
File.write(path, string)
CSV.table(path) # => #<CSV::Table mode:col_or_row row_count:4>

Returns the methods available to this delegate object as the union of this object’s and _getobj_ methods.

Executes the generated ERB code to produce a completed template, returning the results of that code. (See ERB::new for details on how this process can be affected by safe_level.)

b accepts a Binding object which is used to set the context of code evaluation.

Set logging severity threshold.

severity

The Severity of the log message.

Release code

Removes the last List.

Returns the number of elements in the match array.

m = /(.)(.)(\d+)(\d)/.match("THX1138.")
m.length   #=> 5
m.size     #=> 5

This says “you can break a line here if necessary”, and a width-column text sep is inserted if a line is not broken at the point.

If sep is not specified, “ ” is used.

If width is not specified, sep.length is used. You will have to specify this when sep is a multibyte character, for example.

Removes an object hierarchy from the data store, by name.

WARNING: This method is only valid in a PStore#transaction and it cannot be read-only. It will raise PStore::Error if called at any other time.

Sets default task values

No documentation available
No documentation available

Checks if the object is shareable by ractors.

Ractor.shareable?(1)            #=> true -- numbers and other immutable basic values are frozen
Ractor.shareable?('foo')        #=> false, unless the string is frozen due to # freeze_string_literals: true
Ractor.shareable?('foo'.freeze) #=> true

See also the “Shareable and unshareable objects” section in the Ractor class docs.

Activates the trace.

Returns true if trace was enabled. Returns false if trace was disabled.

trace.enabled?  #=> false
trace.enable    #=> false (previous state)
                #   trace is enabled
trace.enabled?  #=> true
trace.enable    #=> true (previous state)
                #   trace is still enabled

If a block is given, the trace will only be enabled within the scope of the block.

trace.enabled?
#=> false

trace.enable do
  trace.enabled?
  # only enabled for this block
end

trace.enabled?
#=> false

target, target_line and target_thread parameters are used to limit tracing only to specified code objects. target should be a code object for which RubyVM::InstructionSequence.of will return an instruction sequence.

t = TracePoint.new(:line) { |tp| p tp }

def m1
  p 1
end

def m2
  p 2
end

t.enable(target: method(:m1))

m1
# prints #<TracePoint:line test.rb:4 in `m1'>
m2
# prints nothing

Note: You cannot access event hooks within the enable block.

trace.enable { p tp.lineno }
#=> RuntimeError: access from outside

Deactivates the trace

Return true if trace was enabled. Return false if trace was disabled.

trace.enabled?      #=> true
trace.disable       #=> true (previous status)
trace.enabled?      #=> false
trace.disable       #=> false

If a block is given, the trace will only be disable within the scope of the block.

trace.enabled?
#=> true

trace.disable do
    trace.enabled?
    # only disabled for this block
end

trace.enabled?
#=> true

Note: You cannot access event hooks within the block.

trace.disable { p tp.lineno }
#=> RuntimeError: access from outside

The current status of the trace

Returns x+i*y;

Complex(1, 2)    #=> (1+2i)
Complex('1+2i')  #=> (1+2i)
Complex(nil)     #=> TypeError
Complex(1, nil)  #=> TypeError

Complex(1, nil, exception: false)  #=> nil
Complex('1+2', exception: false)   #=> nil

Syntax of string form:

string form = extra spaces , complex , extra spaces ;
complex = real part | [ sign ] , imaginary part
        | real part , sign , imaginary part
        | rational , "@" , rational ;
real part = rational ;
imaginary part = imaginary unit | unsigned rational , imaginary unit ;
rational = [ sign ] , unsigned rational ;
unsigned rational = numerator | numerator , "/" , denominator ;
numerator = integer part | fractional part | integer part , fractional part ;
denominator = digits ;
integer part = digits ;
fractional part = "." , digits , [ ( "e" | "E" ) , [ sign ] , digits ] ;
imaginary unit = "i" | "I" | "j" | "J" ;
sign = "-" | "+" ;
digits = digit , { digit | "_" , digit };
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
extra spaces = ? \s* ? ;

See String#to_c.

Search took: 7ms  ·  Total Results: 3178