Results for: "pstore"

No documentation available

Returns the bound receiver of the binding object.

Returns true if the log level allows entries with severity Logger::ERROR to be written, false otherwise. See Log Level.

Sets the log level to Logger::ERROR. See Log Level.

Sets the logger’s output stream:

Example:

logger = Logger.new('t.log')
logger.add(Logger::ERROR, 'one')
logger.close
logger.add(Logger::ERROR, 'two') # Prints 'log writing failed. closed stream'
logger.reopen
logger.add(Logger::ERROR, 'three')
logger.close
File.readlines('t.log')
# =>
# ["# Logfile created on 2022-05-12 14:21:19 -0500 by logger.rb/v1.5.0\n",
#  "E, [2022-05-12T14:21:27.596726 #22428] ERROR -- : one\n",
#  "E, [2022-05-12T14:23:05.847241 #22428] ERROR -- : three\n"]

Equivalent to calling add with severity Logger::ERROR.

No documentation available

Directs to reject specified class argument.

t

Argument class specifier, any object including Class.

reject(t)

See reject.

Release code

No documentation available

Subject of on / on_head, accept / reject

Removes the last List.

No documentation available

Returns option summary list.

Parses command line arguments argv in order. When a block is given, each non-option argument is yielded. When optional into keyword argument is provided, the parsed option values are stored there via []= method (so it can be Hash, or OpenStruct, or other similar object).

Returns the rest of argv left unparsed.

Same as order, but removes switches destructively. Non-option arguments remain in argv.

Wrapper method for getopts.rb.

params = ARGV.getopts("ab:", "foo", "bar:", "zot:Z;zot option")
# params["a"] = true   # -a
# params["b"] = "1"    # -b1
# params["foo"] = "1"  # --foo
# params["bar"] = "x"  # --bar x
# params["zot"] = "z"  # --zot Z

See getopts.

Returns Hash representation of the data object.

Measure = Data.define(:amount, :unit)
distance = Measure[10, 'km']

distance.to_h
#=> {:amount=>10, :unit=>"km"}

Like Enumerable#to_h, if the block is provided, it is expected to produce key-value pairs to construct a hash:

distance.to_h { |name, val| [name.to_s, val.to_s] }
#=> {"amount"=>"10", "unit"=>"km"}

Note that there is a useful symmetry between to_h and initialize:

distance2 = Measure.new(**distance.to_h)
#=> #<data Measure amount=10, unit="km">
distance2 == distance
#=> true

Returns the values in self as an array, to use in pattern matching:

Measure = Data.define(:amount, :unit)

distance = Measure[10, 'km']
distance.deconstruct #=> [10, "km"]

# usage
case distance
in n, 'km' # calls #deconstruct underneath
  puts "It is #{n} kilometers away"
else
  puts "Don't know how to handle it"
end
# prints "It is 10 kilometers away"

Or, with checking the class, too:

case distance
in Measure(n, 'km')
  puts "It is #{n} kilometers away"
# ...
end

Returns a string representation of self:

Measure = Data.define(:amount, :unit)

distance = Measure[10, 'km']

p distance  # uses #inspect underneath
#<data Measure amount=10, unit="km">

puts distance  # uses #to_s underneath, same representation
#<data Measure amount=10, unit="km">

Returns the regexp that produced the match:

m = /a.*b/.match("abc") # => #<MatchData "ab">
m.regexp                # => /a.*b/

Returns the array of matches:

m = /(.)(.)(\d+)(\d)/.match("THX1138.")
# => #<MatchData "HX1138" 1:"H" 2:"X" 3:"113" 4:"8">
m.to_a # => ["HX1138", "H", "X", "113", "8"]

Related: MatchData#captures.

Returns the array of captures, which are all matches except m[0]:

m = /(.)(.)(\d+)(\d)/.match("THX1138.")
# => #<MatchData "HX1138" 1:"H" 2:"X" 3:"113" 4:"8">
m[0]       # => "HX1138"
m.captures # => ["H", "X", "113", "8"]

Related: MatchData.to_a.

Search took: 3ms  ·  Total Results: 3094