Returns true
if and only if the current severity level allows for the printing of WARN
messages.
Sets the severity to WARN.
Initializes a new instance and evaluates the optional block in context of the instance. Arguments args
are passed to new
, see there for description of parameters.
This method is deprecated, its behavior corresponds to the older new
method.
Puts option summary into to
and returns to
. Yields each line if a block is given.
to
Output destination, which must have method <<. Defaults to [].
width
Width of left side, defaults to @summary_width.
max
Maximum length allowed for left side, defaults to width
- 1.
indent
Indentation, defaults to @summary_indent.
Creates an option from the given parameters params
. See Parameters for New Options.
The block, if given, is the handler for the created option. When the option is encountered during command-line parsing, the block is called with the argument given for the option, if any. See Option Handlers.
Parses environment variable env
or its uppercase with splitting like a shell.
env
defaults to the basename of the program.
Returns the path to the data store file.
Ends the current PStore#transaction
, committing any changes to the data store immediately.
require "pstore" store = PStore.new("data_file.pstore") store.transaction do # begin transaction # load some data into the store... store[:one] = 1 store[:two] = 2 store.commit # end transaction here, committing changes store[:three] = 3 # this change is never reached end
WARNING: This method is only valid in a PStore#transaction
. It will raise PStore::Error
if called at any other time.
Ends the current PStore#transaction
, discarding any changes to the data store.
require "pstore" store = PStore.new("data_file.pstore") store.transaction do # begin transaction store[:one] = 1 # this change is not applied, see below... store[:two] = 2 # this change is not applied, see below... store.abort # end transaction here, discard all changes store[:three] = 3 # this change is never reached end
WARNING: This method is only valid in a PStore#transaction
. It will raise PStore::Error
if called at any other time.
Returns the full path name of the temporary file. This will be nil if unlink
has been called.
The reason this block was terminated: :break, :redo, :retry, :next, :return, or :noreason.
Returns a clone of this method.
class A def foo return "bar" end end m = A.new.method(:foo) m.call # => "bar" n = m.clone.call # => "bar"
Returns a clone of this method.
class A def foo return "bar" end end m = A.new.method(:foo) m.call # => "bar" n = m.clone.call # => "bar"
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.
Terminates the currently running thread and schedules another thread to be run.
If this thread is already marked to be killed, ::exit
returns the Thread
.
If this is the main thread, or the last thread, exit the process.
Give the thread scheduler a hint to pass execution to another thread. A running thread may or may not switch, it depends on OS and processor.
Terminates thr
and schedules another thread to be run, returning the terminated Thread
. If this is the main thread, or the last thread, exits the process.
Path of the file being run
If object is string-like, parse the string and return the parsed result as a Ruby data structure. Otherwise, generate a JSON
text from the Ruby data structure object and return it.
The opts argument is passed through to generate/parse respectively. See generate and parse for their documentation.
Creates a new Pathname
object from the given string, path
, and returns pathname object.
In order to use this constructor, you must first require the Pathname
standard library extension.
require 'pathname' Pathname("/home/zzak") #=> #<Pathname:/home/zzak>
See also Pathname::new
for more information.
Produces a shallow copy of obj—the instance variables of obj are copied, but not the objects they reference. clone
copies the frozen value state of obj, unless the :freeze
keyword argument is given with a false or true value. See also the discussion under Object#dup
.
class Klass attr_accessor :str end s1 = Klass.new #=> #<Klass:0x401b3a38> s1.str = "Hello" #=> "Hello" s2 = s1.clone #=> #<Klass:0x401b3998 @str="Hello"> s2.str[1,4] = "i" #=> "i" s1.inspect #=> "#<Klass:0x401b3a38 @str=\"Hi\">" s2.inspect #=> "#<Klass:0x401b3998 @str=\"Hi\">"
This method may have class-specific behavior. If so, that behavior will be documented under the #initialize_copy
method of the class.
Returns arg
as an Array
.
First tries to call to_ary
on arg
, then to_a
. If arg
does not respond to to_ary
or to_a
, returns an Array
of length 1 containing arg
.
If to_ary
or to_a
returns something other than an Array
, raises a TypeError
.
Array(["a", "b"]) #=> ["a", "b"] Array(1..5) #=> [1, 2, 3, 4, 5] Array(key: :value) #=> [[:key, :value]] Array(nil) #=> [] Array(1) #=> [1]