Swift Interop
These types and extensions are used to convert Swift datatypes to Ruby and vice versa.
Topics
protocol RbObjectConvertible
protocol RbObjectConvertible
Protocol adopted by types that can be converted to and from RbObject
s.
Declaration
public protocol RbObjectConvertible
extension String
extension String
A Unicode string value that is a collection of characters.
Declaration
extension String: RbObjectConvertible
extension Bool
extension Bool
A value type whose instances are either true
or false
.
Declaration
extension Bool: RbObjectConvertible
extension UInt
extension UInt
extension UInt64
extension UInt64
extension UInt32
extension UInt32
extension UInt16
extension UInt16
extension UInt8
extension UInt8
extension Int
extension Int
extension Int64
extension Int64
extension Int32
extension Int32
extension Int16
extension Int16
extension Int8
extension Int8
extension Double
extension Double
A double-precision, floating-point value type.
Declaration
extension Double: RbObjectConvertible
extension Float
extension Float
A single-precision, floating-point value type.
Declaration
extension Float: RbObjectConvertible
extension Array
extension Array
These methods are available only when the array Element
type conforms
to RbObjectConvertible
.
Declaration
extension Array: RbObjectConvertible where Element: RbObjectConvertible
extension ArraySlice
extension ArraySlice
These methods are available only when the array slice Element
type
conforms to RbObjectConvertible
.
Declaration
extension ArraySlice: RbObjectConvertible where Element: RbObjectConvertible
extension Dictionary
extension Dictionary
These methods are available only when both the dictionary Key
and Value
types conform to RbObjectConvertible
.
Declaration
extension Dictionary: RbObjectConvertible
where Key: RbObjectConvertible, Value: RbObjectConvertible
extension Set
extension Set
These methods are available only when the set Element
type conforms
to RbObjectConvertible
.
Declaration
extension Set: RbObjectConvertible where Element: RbObjectConvertible
extension Range
extension Range
These methods are available only when the range Bound
type conforms to
RbObjectConvertible
.
Declaration
extension Range: RbObjectConvertible where Bound: RbObjectConvertible
extension ClosedRange
extension ClosedRange
These methods are available only when the range Bound
type conforms to
RbObjectConvertible
.
Declaration
extension ClosedRange: RbObjectConvertible where Bound: RbObjectConvertible
struct RbComplex
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
public struct RbComplex: RbObjectConvertible
struct RbRational
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
public struct RbRational: RbObjectConvertible