Results for: "strip"

Updates the GC stress mode.

When stress mode is enabled, the GC is invoked at every GC opportunity: all memory and object allocations.

Enabling stress mode will degrade performance, it is only for debugging.

flag can be true, false, or an integer bit-ORed following flags.

0x01:: no major GC
0x02:: no immediate sweep
0x04:: full mark after malloc/calloc/realloc

Gets the scheduling priority for specified process, process group, or user. kind indicates the kind of entity to find: one of Process::PRIO_PGRP, Process::PRIO_USER, or Process::PRIO_PROCESS. integer is an id indicating the particular process, process group, or user (an id of 0 means current). Lower priorities are more favorable for scheduling. Not available on all platforms.

Process.getpriority(Process::PRIO_USER, 0)      #=> 19
Process.getpriority(Process::PRIO_PROCESS, 0)   #=> 19

See Process.getpriority.

Process.setpriority(Process::PRIO_USER, 0, 19)      #=> 0
Process.setpriority(Process::PRIO_PROCESS, 0, 19)   #=> 0
Process.getpriority(Process::PRIO_USER, 0)          #=> 19
Process.getpriority(Process::PRIO_PROCESS, 0)       #=> 19

Performs a Miller-Rabin probabilistic primality test for bn.

Deprecated in version 3.0. Use prime? instead.

checks and trial_div parameters no longer have any effect.

Called with encoding when the YAML stream starts. This method is called once per stream. A stream may contain multiple documents.

See the constants in Psych::Parser for the possible values of encoding.

No documentation available

Start a stream emission with encoding

See Psych::Handler#start_stream

Read a chunk or all of the buffer into a string, in the specified encoding. If no encoding is provided Encoding::BINARY is used.

buffer = IO::Buffer.for('test')
buffer.get_string
# => "test"
buffer.get_string(2)
# => "st"
buffer.get_string(2, 1)
# => "s"

Efficiently copy data from a source String into the buffer, at offset using memcpy.

buf = IO::Buffer.new(8)
# =>
# #<IO::Buffer 0x0000557412714a20+8 INTERNAL>
# 0x00000000  00 00 00 00 00 00 00 00                         ........

# set data starting from offset 1, take 2 bytes starting from string's
# second
buf.set_string('test', 1, 2, 1)
# => 2
buf
# =>
# #<IO::Buffer 0x0000557412714a20+8 INTERNAL>
# 0x00000000  00 65 73 00 00 00 00 00                         .es.....

See also copy for examples of how buffer writing might be used for changing associated strings and files.

No documentation available
No documentation available
No documentation available

Sanitize a single string.

Returns a status string for the response.

If the SOURCE_DATE_EPOCH environment variable is set, returns it’s value. Otherwise, returns the time that Gem.source_date_epoch_string was first called in the same format as SOURCE_DATE_EPOCH.

NOTE(@duckinator): The implementation is a tad weird because we want to:

1. Make builds reproducible by default, by having this function always
   return the same result during a given run.
2. Allow changing ENV['SOURCE_DATE_EPOCH'] at runtime, since multiple
   tests that set this variable will be run in a single process.

If you simplify this function and a lot of tests fail, that is likely due to #2 above.

Details on SOURCE_DATE_EPOCH: reproducible-builds.org/specs/source-date-epoch/

Returns self if self is a String, or self converted to a String if self is a subclass of String.

String#to_str is an alias for String#to_s.

Returns an array of instance variable names for the receiver. Note that simply defining an accessor does not create the corresponding instance variable.

class Fred
  attr_accessor :a1
  def initialize
    @iv = 3
  end
end
Fred.new.instance_variables   #=> [:@iv]

Creates an accessor method to allow assignment to the attribute symbol.id2name. String arguments are converted to symbols. Returns an array of defined method names as symbols.

Makes a list of existing constants private.

Returns a hash of the name/value pairs, to use in pattern matching. Possible keys are: :year, :month, :day, :wday, :yday.

Possible usages:

d = Date.new(2022, 10, 5)

if d in wday: 3, day: ..7  # uses deconstruct_keys underneath
  puts "first Wednesday of the month"
end
#=> prints "first Wednesday of the month"

case d
in year: ...2022
  puts "too old"
in month: ..9
  puts "quarter 1-3"
in wday: 1..5, month:
  puts "working day in month #{month}"
end
#=> prints "working day in month 10"

Note that deconstruction by pattern can also be combined with class check:

if d in Date(wday: 3, day: ..7)
  puts "first Wednesday of the month"
end

Returns a hash of the name/value pairs, to use in pattern matching. Possible keys are: :year, :month, :day, :wday, :yday, :hour, :min, :sec, :sec_fraction, :zone.

Possible usages:

dt = DateTime.new(2022, 10, 5, 13, 30)

if d in wday: 1..5, hour: 10..18  # uses deconstruct_keys underneath
  puts "Working time"
end
#=> prints "Working time"

case dt
in year: ...2022
  puts "too old"
in month: ..9
  puts "quarter 1-3"
in wday: 1..5, month:
  puts "working day in month #{month}"
end
#=> prints "working day in month 10"

Note that deconstruction by pattern can also be combined with class check:

if d in DateTime(wday: 1..5, hour: 10..18, day: ..7)
  puts "Working time, first week of the month"
end

Returns a hash of the name/value pairs, to use in pattern matching. Possible keys are: :year, :month, :day, :yday, :wday, :hour, :min, :sec, :subsec, :dst, :zone.

Possible usages:

t = Time.utc(2022, 10, 5, 21, 25, 30)

if t in wday: 3, day: ..7  # uses deconstruct_keys underneath
  puts "first Wednesday of the month"
end
#=> prints "first Wednesday of the month"

case t
in year: ...2022
  puts "too old"
in month: ..9
  puts "quarter 1-3"
in wday: 1..5, month:
  puts "working day in month #{month}"
end
#=> prints "working day in month 10"

Note that deconstruction by pattern can also be combined with class check:

if t in Time(wday: 3, day: ..7)
  puts "first Wednesday of the month"
end

Waits until IO is priority and returns a truthy value or a falsy value when times out. Priority data is sent and received using the Socket::MSG_OOB flag and is typically limited to streams.

You must require ‘io/wait’ to use this method.

Copies from the given src to the given dst, returning the number of bytes copied.

The examples here use file t.txt as source:

File.read('t.txt')
# => "First line\nSecond line\n\nThird line\nFourth line\n"
File.read('t.txt').size # => 47

If only arguments src and dst are given, the entire source stream is copied:

# Paths.
IO.copy_stream('t.txt', 't.tmp')  # => 47

# IOs (recall that a File is also an IO).
src_io = File.open('t.txt', 'r') # => #<File:t.txt>
dst_io = File.open('t.tmp', 'w') # => #<File:t.tmp>
IO.copy_stream(src_io, dst_io)   # => 47
src_io.close
dst_io.close

With argument src_length a non-negative integer, no more than that many bytes are copied:

IO.copy_stream('t.txt', 't.tmp', 10) # => 10
File.read('t.tmp')                   # => "First line"

With argument src_offset also given, the source stream is read beginning at that offset:

IO.copy_stream('t.txt', 't.tmp', 11, 11) # => 11
IO.read('t.tmp')                         # => "Second line"

Returns a hash of the name/value pairs for the given member names.

Customer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
h = joe.deconstruct_keys([:zip, :address])
h # => {:zip=>12345, :address=>"123 Maple, Anytown NC"}

Returns all names and values if array_of_names is nil:

h = joe.deconstruct_keys(nil)
h # => {:name=>"Joseph Smith, Jr.", :address=>"123 Maple, Anytown NC", :zip=>12345}
Search took: 3ms  ·  Total Results: 1534