Swift Interop

These types and extensions are used to convert Swift datatypes to Ruby and vice versa.


Topics

protocol RbObjectConvertible

Protocol adopted by types that can be converted to and from RbObjects.

Declaration
Swift
public protocol RbObjectConvertible

extension String

A Unicode string value that is a collection of characters.

Declaration
Swift
extension String: RbObjectConvertible

extension Bool

A value type whose instances are either true or false.

Declaration
Swift
extension Bool: RbObjectConvertible

extension UInt

An unsigned integer value type.

Declaration
Swift
extension UInt: RbObjectConvertible

extension UInt64

A 64-bit unsigned integer value type.

Declaration
Swift
extension UInt64: RbObjectConvertible

extension UInt32

A 32-bit unsigned integer value type.

Declaration
Swift
extension UInt32: RbObjectConvertible

extension UInt16

A 16-bit unsigned integer value type.

Declaration
Swift
extension UInt16: RbObjectConvertible

extension UInt8

An 8-bit unsigned integer value type.

Declaration
Swift
extension UInt8: RbObjectConvertible

extension Int

A signed integer value type.

Declaration
Swift
extension Int: RbObjectConvertible

extension Int64

A 64-bit signed integer value type.

Declaration
Swift
extension Int64: RbObjectConvertible

extension Int32

A 32-bit signed integer value type.

Declaration
Swift
extension Int32: RbObjectConvertible

extension Int16

A 16-bit signed integer value type.

Declaration
Swift
extension Int16: RbObjectConvertible

extension Int8

An 8-bit signed integer value type.

Declaration
Swift
extension Int8: RbObjectConvertible

extension Double

A double-precision, floating-point value type.

Declaration
Swift
extension Double: RbObjectConvertible

extension Float

A single-precision, floating-point value type.

Declaration
Swift
extension Float: RbObjectConvertible

extension Array

These methods are available only when the array Element type conforms to RbObjectConvertible.

Declaration
Swift
extension Array: RbObjectConvertible where Element: RbObjectConvertible

extension ArraySlice

These methods are available only when the array slice Element type conforms to RbObjectConvertible.

Declaration
Swift
extension ArraySlice: RbObjectConvertible where Element: RbObjectConvertible

extension Dictionary

These methods are available only when both the dictionary Key and Value types conform to RbObjectConvertible.

Declaration

extension Set

These methods are available only when the set Element type conforms to RbObjectConvertible.

Declaration
Swift
extension Set: RbObjectConvertible where Element: RbObjectConvertible

extension Range

These methods are available only when the range Bound type conforms to RbObjectConvertible.

Declaration
Swift
extension Range: RbObjectConvertible where Bound: RbObjectConvertible

extension ClosedRange

These methods are available only when the range Bound type conforms to RbObjectConvertible.

Declaration
Swift
extension ClosedRange: RbObjectConvertible where Bound: RbObjectConvertible

struct RbComplex

A simple interface to Ruby’s complex number support.

This is not a Swift complex number library. It could be used as an interface between one such and Ruby.

Ruby always represents complex numbers internally using rectangular coordinates so this type does not offer any direct support for polar coordinates.

Declaration
Swift
public struct RbComplex: RbObjectConvertible

struct RbRational

A simple interface to Ruby’s rational number support.

This is not a Swift rational number library. It could be used as an interface between one such and Ruby.

Ruby represents rational numbers internally as a positive or negative integer numerator and a positive integer denominator. Instances of this RbRational type converted from Ruby objects follow these rules; instances produced by Swift code using the RbRational.init(numerator:denominator:) method may not.

let myRat = RbRational(numerator: myFractionTop, denominator: myFractionBot)

let resultObj = myRubyService.call("addFinalSample", args: [myRat])

let myRatResult = RbRational(resultObj)
Declaration
Swift
public struct RbRational: RbObjectConvertible