Used to filter unwanted trace output
Example which only outputs lines of code executed within the Kernel
class:
Tracer.add_filter do |event, file, line, id, binding, klass, *rest| "Kernel" == klass.to_s end
Creates a new compiler for ERB
. See ERB::Compiler.new for details
Returns a new binding each time near TOPLEVEL_BINDING for runs that do not specify a binding.
Return the appropriate error message in POSIX-defined format. If no error has occurred, returns nil.
Returns true if the ipaddr is an IPv4-compatible IPv6 address.
Returns a new ipaddr built by converting the native IPv4 address into an IPv4-compatible IPv6 address.
Returns the names of the binding’s local variables as symbols.
def foo a = 1 2.times do |n| binding.local_variables #=> [:a, :n] end end
This method is the short version of the following code:
binding.eval("local_variables")
Set
date-time format.
datetime_format
A string suitable for passing to strftime
.
Returns the date format being used. See datetime_format=
Returns the submatrix obtained by deleting the specified row and column.
Matrix.diagonal(9, 5, -3, 4).first_minor(1, 2) => 9 0 0 0 0 0 0 0 4
Hadamard product
Matrix[[1,2], [3,4]].hadamard_product(Matrix[[1,2], [3,2]]) => 1 4 9 8
Returns an array of the row vectors of the matrix. See Vector
.
Returns an array of the column vectors of the matrix. See Vector
.
Returns the inner product of this vector with the other.
Vector[4,7].inner_product Vector[10,1] => 47
Returns a Hash
using named capture.
A key of the hash is a name of the named captures. A value of the hash is a string of last successful capture of corresponding group.
m = /(?<a>.)(?<b>.)/.match("01") m.named_captures #=> {"a" => "0", "b" => "1"} m = /(?<a>.)(?<b>.)?/.match("0") m.named_captures #=> {"a" => "0", "b" => nil} m = /(?<a>.)(?<a>.)/.match("01") m.named_captures #=> {"a" => "1"} m = /(?<a>x)|(?<a>y)/.match("x") m.named_captures #=> {"a" => "x"}