RbProc

Swift
public struct RbProc: RbObjectConvertible

A Ruby Proc.

Use this to create a Ruby Proc from a symbol or any Ruby object supporting to_proc.

This is most useful when passing a block to a method:

// Ruby: mapped = names.map(&:downcase)
let mapped = names.call("map", block: RbProc(RbSymbol("downcase")))

Use RbObject.init(blockCall:) to create a Ruby Proc from a Swift closure.

If you want to pass Swift code to a method as a block then just call RbObjectAccess.call(_:args:kwArgs:blockRetention:blockCall:) directly, no need for either RbProc or RbObject.


Topics

init(object: RbObjectConvertible)

Initialize from something that can be turned into a Ruby object.

Declaration
Swift
public init(object: RbObjectConvertible)

init?(RbObject)

Try to initialize from a Ruby object.

Succeeds if the object can be used as a Proc (has to_proc).

Declaration
Swift
public init?(_ value: RbObject)

var rubyObject: RbObject

A Ruby object for the Proc

Declaration
Swift
public var rubyObject: RbObject { get }