Class: PyBind::PyObjectStruct

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/pybind/struct.rb,
lib/pybind/typecast.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.nullObject



8
9
10
# File 'lib/pybind/struct.rb', line 8

def self.null
  new(FFI::Pointer::NULL)
end

Instance Method Details

#kind_of?(klass) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
25
# File 'lib/pybind/struct.rb', line 16

def kind_of?(klass)
  case klass
  when PyBind::PyObjectStruct
    value = LibPython.PyObject_IsInstance(self, klass)
    raise PyError.fetch if value == -1
    value == 1
  else
    super
  end
end

#none?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/pybind/struct.rb', line 12

def none?
  PyBind.None.to_ptr == to_ptr
end

#to_python_structObject Also known as: to_python



31
32
33
# File 'lib/pybind/struct.rb', line 31

def to_python_struct
  self
end

#to_rubyObject



24
25
26
# File 'lib/pybind/typecast.rb', line 24

def to_ruby
  TypeCast.from_python(self)
end

#to_ruby_objectObject



27
28
29
# File 'lib/pybind/struct.rb', line 27

def to_ruby_object
  PyObject.new(self)
end