class PyCall::GCGuard::Key

Public Class Methods

new(pyptr) click to toggle source
# File lib/pycall/gc_guard.rb, line 8
def initialize(pyptr)
  self.pyptr = check_pyptr(pyptr)
  # LibPython.Py_IncRef(pyptr)
end

Public Instance Methods

==(other) click to toggle source
Calls superclass method
# File lib/pycall/gc_guard.rb, line 18
def ==(other)
  case other
  when Key
    pyptr.pointer == other.pyptr.pointer
  else
    super
  end
end
Also aliased as: eql?
eql?(other)
Alias for: ==
hash() click to toggle source
# File lib/pycall/gc_guard.rb, line 29
def hash
  pyptr.pointer.address
end
release() click to toggle source
# File lib/pycall/gc_guard.rb, line 13
def release
  # LibPython.Py_DecRef(pyptr)
  self.pyptr = nil
end

Private Instance Methods

check_pyptr(pyptr) click to toggle source
# File lib/pycall/gc_guard.rb, line 35
def check_pyptr(pyptr)
  pyptr = pyptr.__pyobj__ if pyptr.respond_to? :__pyobj__
  return pyptr if pyptr.kind_of? LibPython::PyObjectStruct
  raise TypeError, "The argument must be a Python object"
end