Results for: "Array.new"

Vector.new is private; use Vector[] or Vector.elements to create.

Initializes the instance and yields itself if called with a block.

banner

Banner message.

width

Summary width.

indent

Summary indent.

Pushes a new List.

Creates a buffer for pretty printing.

output is an output target. If it is not specified, ” is assumed. It should have a << method which accepts the first argument obj of PrettyPrint#text, the first argument sep of PrettyPrint#breakable, the first argument newline of PrettyPrint.new, and the result of a given block for PrettyPrint.new.

maxwidth specifies maximum line length. If it is not specified, 79 is assumed. However actual outputs may overflow maxwidth if long non-breakable texts are provided.

newline is used for line breaks. “n” is used if it is not specified.

The block is used to generate spaces. {|width| ‘ ’ * width} is used if it is not given.

To construct a PStore object, pass in the file path where you would like the data to be stored.

PStore objects are always reentrant. But if thread_safe is set to true, then it will become thread-safe at the cost of a minor performance hit.

Create an RDoc task with the given name. See the RDoc::Task class overview for documentation.

Creates a new Resolv using resolvers.

Creates a temporary file with permissions 0600 (= only readable and writable by the owner) and opens it with mode “w+”.

It is recommended to use Tempfile.create { … } instead when possible, because that method avoids the cost of delegation and does not rely on a finalizer to close and unlink the file, which is unreliable.

The basename parameter is used to determine the name of the temporary file. You can either pass a String or an Array with 2 String elements. In the former form, the temporary file’s base name will begin with the given string. In the latter form, the temporary file’s base name will begin with the array’s first element, and end with the second element. For example:

file = Tempfile.new('hello')
file.path  # => something like: "/tmp/hello2843-8392-92849382--0"

# Use the Array form to enforce an extension in the filename:
file = Tempfile.new(['hello', '.jpg'])
file.path  # => something like: "/tmp/hello2843-8392-92849382--0.jpg"

The temporary file will be placed in the directory as specified by the tmpdir parameter. By default, this is Dir.tmpdir.

file = Tempfile.new('hello', '/home/aisaka')
file.path  # => something like: "/home/aisaka/hello2843-8392-92849382--0"

You can also pass an options hash. Under the hood, Tempfile creates the temporary file using File.open. These options will be passed to File.open. This is mostly useful for specifying encoding options, e.g.:

Tempfile.new('hello', '/home/aisaka', encoding: 'ascii-8bit')

# You can also omit the 'tmpdir' parameter:
Tempfile.new('hello', encoding: 'ascii-8bit')

Note: mode keyword argument, as accepted by Tempfile, can only be numeric, combination of the modes defined in File::Constants.

Exceptions

If Tempfile.new cannot find a unique filename within a limited number of tries, then it will raise an exception.

Creates a weak reference to orig

Raises an ArgumentError if the given orig is immutable, such as Symbol, Integer, or Float.

Creates a new Proc object, bound to the current context. Proc::new may be called without a block only within a method with an attached block, in which case that block is converted to the Proc object.

def proc_from
  Proc.new
end
proc = proc_from { "hello" }
proc.call   #=> "hello"

Create a new Ractor with args and a block.

A block (Proc) will be isolated (can’t access to outer variables). self inside the block will refer to the current Ractor.

r = Ractor.new { puts "Hi, I am #{self.inspect}" }
r.take
# Prints "Hi, I am #<Ractor:#2 test.rb:1 running>"

args passed to the method would be propagated to block args by the same rules as objects passed through send/Ractor.receive: if args are not shareable, they will be copied (via deep cloning, which might be inefficient).

arg = [1, 2, 3]
puts "Passing: #{arg} (##{arg.object_id})"
r = Ractor.new(arg) {|received_arg|
  puts "Received: #{received_arg} (##{received_arg.object_id})"
}
r.take
# Prints:
#   Passing: [1, 2, 3] (#280)
#   Received: [1, 2, 3] (#300)

Ractor’s name can be set for debugging purposes:

r = Ractor.new(name: 'my ractor') {}
p r
#=> #<Ractor:#3 my ractor test.rb:1 terminated>

Creates a new PRNG using seed to set the initial state. If seed is omitted, the generator is initialized with Random.new_seed.

See Random.srand for more information on the use of seed values.

Creates a new thread executing the given block.

Any args given to ::new will be passed to the block:

arr = []
a, b, c = 1, 2, 3
Thread.new(a,b,c) { |d,e,f| arr << d << e << f }.join
arr #=> [1, 2, 3]

A ThreadError exception is raised if ::new is called without a block.

If you’re going to subclass Thread, be sure to call super in your initialize method, otherwise a ThreadError will be raised.

Creates a new Mutex

Creates a new condition variable instance.

Creates a new queue instance.

Creates a fixed-length queue with a maximum size of max.

Returns a new TracePoint object, not enabled by default.

Next, in order to activate the trace, you must use TracePoint#enable

trace = TracePoint.new(:call) do |tp|
    p [tp.lineno, tp.defined_class, tp.method_id, tp.event]
end
#=> #<TracePoint:disabled>

trace.enable
#=> false

puts "Hello, TracePoint!"
# ...
# [48, IRB::Notifier::AbstractNotifier, :printf, :call]
# ...

When you want to deactivate the trace, you must use TracePoint#disable

trace.disable

See Events at TracePoint for possible events and more information.

A block must be given, otherwise an ArgumentError is raised.

If the trace method isn’t included in the given events filter, a RuntimeError is raised.

TracePoint.trace(:line) do |tp|
    p tp.raised_exception
end
#=> RuntimeError: 'raised_exception' not supported by this event

If the trace method is called outside block, a RuntimeError is raised.

TracePoint.trace(:line) do |tp|
  $tp = tp
end
$tp.lineno #=> access from outside (RuntimeError)

Access from other threads is also forbidden.

Document-class: UncaughtThrowError

Raised when throw is called with a tag which does not have corresponding catch block.

throw "foo", "bar"

raises the exception:

UncaughtThrowError: uncaught throw "foo"

Use extend MonitorMixin or include MonitorMixin instead of this constructor. Have look at the examples above to understand how to use this module.

No documentation available

Duplicates self and resets its day of calendar reform.

d = Date.new(1582,10,15)
d.new_start(Date::JULIAN)         #=> #<Date: 1582-10-05 ...>

Returns OLE event object. The first argument specifies WIN32OLE object. The second argument specifies OLE event name.

ie = WIN32OLE.new('InternetExplorer.Application')
ev = WIN32OLE_EVENT.new(ie, 'DWebBrowserEvents')

Returns a new WIN32OLE_METHOD object which represents the information about OLE method. The first argument ole_type specifies WIN32OLE_TYPE object. The second argument method specifies OLE method name defined OLE class which represents WIN32OLE_TYPE object.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
method = WIN32OLE_METHOD.new(tobj, 'SaveAs')

Returns WIN32OLE_PARAM object which represents OLE parameter information. 1st argument should be WIN32OLE_METHOD object. 2nd argument ‘n’ is n-th parameter of the method specified by 1st argument.

tobj = WIN32OLE_TYPE.new('Microsoft Scripting Runtime', 'IFileSystem')
method = WIN32OLE_METHOD.new(tobj, 'CreateTextFile')
param = WIN32OLE_PARAM.new(method, 2) # => #<WIN32OLE_PARAM:Overwrite=true>
Search took: 4ms  ·  Total Results: 2131