Method: RubyPython::Conversion.rtopObject

Defined in:
lib/rubypython/conversion.rb

.rtopObject(rObj, is_key = false) ⇒ FFI::Pointer

If possible converts a ruby type to an equivalent python native type.

Parameters:

  • rObj

    a native ruby type

  • is_key (Boolean) (defaults to: false)

    whether this object will be used as a key in a python dict.

Returns:

  • (FFI::Pointer)

    a to a C PyObject*

Raises:



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/rubypython/conversion.rb', line 75

def self.rtopObject(rObj, is_key=false)
  case rObj
  when String
    rtopString rObj
  when Array
    # If this object is going to be used as a
    # hash key we should make it a tuple instead
    # of a list
    if is_key
      rtopArrayToTuple rObj
    else
      rtopArrayToList rObj
    end
  when Hash
    rtopHash rObj
  when Fixnum
    rtopFixnum rObj
  when Bignum
    rtopBignum rObj
  when Float
    rtopFloat rObj
  when true
    rtopTrue
  when false
    rtopFalse
  when Symbol
    rtopSymbol rObj
  when nil
    rtopNone
  else
    raise UnsupportedConversion.new("Unsupported type for RTOP conversion." )
  end
end